[cfe-commits] r109537 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/qualified-member-enum.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Jul 27 13:51:02 PDT 2010
Author: efriedma
Date: Tue Jul 27 15:51:02 2010
New Revision: 109537
URL: http://llvm.org/viewvc/llvm-project?rev=109537&view=rev
Log:
Fix a minor crash bug with constructs like Obj.Class::ENUM_VALUE.
Added:
cfe/trunk/test/SemaCXX/qualified-member-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=109537&r1=109536&r2=109537&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul 27 15:51:02 2010
@@ -2628,12 +2628,12 @@
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;
Added: cfe/trunk/test/SemaCXX/qualified-member-enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/qualified-member-enum.cpp?rev=109537&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/qualified-member-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/qualified-member-enum.cpp Tue Jul 27 15:51:02 2010
@@ -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;
+}
+
More information about the cfe-commits
mailing list