Fix a minor crash bug with constructs like Obj.Class::ENUM_VALUE.

llvm-svn: 109537
This commit is contained in:
Eli Friedman 2010-07-27 20:51:02 +00:00
parent 4f6e73b168
commit 7530049b16
2 changed files with 14 additions and 4 deletions

View File

@ -2628,12 +2628,12 @@ bool Sema::CheckQualifiedMemberReference(Expr *BaseExpr,
return false;
// Note that we use the DC of the decl, not the underlying decl.
CXXRecordDecl *RecordD = cast<CXXRecordDecl>((*I)->getDeclContext());
while (RecordD->isAnonymousStructOrUnion())
RecordD = cast<CXXRecordDecl>(RecordD->getParent());
DeclContext *DC = (*I)->getDeclContext();
while (DC->isTransparentContext())
DC = DC->getParent();
llvm::SmallPtrSet<CXXRecordDecl*,4> MemberRecord;
MemberRecord.insert(RecordD->getCanonicalDecl());
MemberRecord.insert(cast<CXXRecordDecl>(DC)->getCanonicalDecl());
if (!IsProvablyNotDerivedFrom(*this, BaseRecord, MemberRecord))
return false;

View File

@ -0,0 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Check that this doesn't crash.
struct A {
enum {LABEL};
};
int f() {
return A().A::LABEL;
}