Look through using decls when classifying implicit member access
Clang will now accept this valid C++11 code:
struct A { int field; };
struct B : A {
using A::field;
enum { TheSize = sizeof(field) };
};
Previously we would classify the 'field' reference as something other
than a field, and then forget to apply the C++11 rule to allow
non-static data member references in unevaluated contexts.
This usually arises in class templates that want to reference fields of
a dependent base in an unevaluated context outside of an instance
method. Such contexts do not allow references to 'this', so the only way
to access the field is with a using decl and an implicit member
reference.
llvm-svn: 250839
This commit is contained in:
@@ -102,8 +102,9 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
|
||||
bool hasNonInstance = false;
|
||||
bool isField = false;
|
||||
BaseSet Classes;
|
||||
for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I) {
|
||||
NamedDecl *D = *I;
|
||||
for (NamedDecl *D : R) {
|
||||
// Look through any using decls.
|
||||
D = D->getUnderlyingDecl();
|
||||
|
||||
if (D->isCXXInstanceMember()) {
|
||||
isField |= isa<FieldDecl>(D) || isa<MSPropertyDecl>(D) ||
|
||||
@@ -111,8 +112,7 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
|
||||
|
||||
CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
Classes.insert(R->getCanonicalDecl());
|
||||
}
|
||||
else
|
||||
} else
|
||||
hasNonInstance = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user