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

Nikola Smiljanic popizdeh at gmail.com
Fri Aug 17 03:12:15 PDT 2012


> You should make this a non-optional argument;  I think that should be
> fine for all the callers.  (Your implementation isn't safe against null
> lookup results anyway, but it doesn't matter, because you don't need
> to rely on that.)

I tried doing this, passed LookupResult by reference and had to change
the signature of BuildDeclarationNameExpr because it's calling
BuildAnonymousStructUnionMemberReference and doesn't have a
LookupResult to pass. Now the same thing happens with
RebuildDeclRefExpr that calls BuildDeclarationNameExpr and doesn't
have a LookupResult to pass. I went up the call chain, but couldn't
figure out where to get the LookupResult?

> That is not the real found-decl info. :)  You're implicitly stripping off
> UsingShadowDecls and the found access path.  You just want *R->begin().

In that case should I use *R->begin() or R->getRepresentativeDecl()?

And is there a test case I could write to make sure this FIXME was
actually fixed, because getFoundDecl and *begin() are the same in my
example?

> This is in the implicit member access case, right?  You don't need to check
> for a pointer type — the base expression is always 'this' and therefore
> always has pointer type.

This 'if' was an assert at first, but when I ran the test suite it
fired on this insanity from CodeGen/init.c:

typedef union vec3 {
  struct { double x, y, z; };
  double component[3];
} vec3;
vec3 f5(vec3 value) {
  return (vec3) {{
    .x = value.x
  }};
}

Do you know the right place to add a test for this PR?




More information about the cfe-commits mailing list