[cfe-commits] protected anonymous union member not visible in derived class

John McCall rjmccall at apple.com
Sun Jan 27 13:04:45 PST 2013


On Aug 22, 2012, at 6:31 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> On Fri, Aug 17, 2012 at 10:11 PM, John McCall <rjmccall at apple.com> wrote:
>> This is from building value.x, right?  That's not the implicit member access case.
>> It is definitely possible for an actual base expression to be non-null.
> 
> This should be it (test included).
> 
> However I do have some questions:
> 
> I'm using the real decl only for building the fist member access. The
> rest of them are still built with FieldDecls that are obtained from
> indirectField. There's even a FIXIT that says "these are somewhat
> meaningless", but I don't know what it refers to. Should this stay the
> same or should I use the real decl here too?

No, that's fine.  You can just remove the FIXME (although please leave
in the comment about the found-declaration being meaningless, which
is still true).

+    assert(R->getResultKind() == LookupResult::Found);
+    NamedDecl *ND = *R->begin();
+    DeclAccessPair foundDecl = DeclAccessPair::make(ND, ND->getAccess());

In general, creating a DeclAccessPair like this for a non-artificial access
is wrong.  The LookupResult actually stores DeclAccessPairs;  you just want
R->begin().getPair().

Making the LookupResult an optional argument seems wrong to me.
Instead, require it to be passed by reference.  This should also allow
you to to drop the 'loc' parameter, which becomes redundant with
R.getNameLoc().

> The 'if (!baseVariable)' block ends with 'baseObjectIsPointer = false'
> but this variable is never used after this. I'm guessing that you
> wanted the variable to remain valid throughout the function, but maybe
> the assignment should be removed?

This looks to be residue from a point in time when the first field
reference was built in a loop with all the others.  You can just
remove this assignment.

John.




More information about the cfe-commits mailing list