[cfe-commits] r104444 - in /cfe/trunk: lib/Sema/Sema.cpp test/SemaCXX/class.cpp
Douglas Gregor
dgregor at apple.com
Sat May 22 09:25:05 PDT 2010
Author: dgregor
Date: Sat May 22 11:25:05 2010
New Revision: 104444
URL: http://llvm.org/viewvc/llvm-project?rev=104444&view=rev
Log:
When determining whether we can use "this", make sure to look through
enum contexts (along with block contexts, which we already did). Fixes
PR7196.
Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/SemaCXX/class.cpp
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=104444&r1=104443&r2=104444&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat May 22 11:25:05 2010
@@ -305,7 +305,7 @@
DeclContext *Sema::getFunctionLevelDeclContext() {
DeclContext *DC = CurContext;
- while (isa<BlockDecl>(DC))
+ while (isa<BlockDecl>(DC) || isa<EnumDecl>(DC))
DC = DC->getParent();
return DC;
Modified: cfe/trunk/test/SemaCXX/class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=104444&r1=104443&r2=104444&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/class.cpp (original)
+++ cfe/trunk/test/SemaCXX/class.cpp Sat May 22 11:25:05 2010
@@ -147,3 +147,15 @@
ec.member = 0;
}
}
+
+namespace PR7196 {
+ struct A {
+ int a;
+
+ void f() {
+ char i[sizeof(a)];
+ enum { x = sizeof(i) };
+ enum { y = sizeof(a) };
+ }
+ };
+}
More information about the cfe-commits
mailing list