aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-22 16:25:05 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-22 16:25:05 +0000
commitd9008318fe395dcbb9049cfb4f2b87cfb5a75f3a (patch)
tree24efb289f4572143795a80dee82e408447d7733b
parent0fddb97901dbe36a8253dee29961cba8e0a87cf6 (diff)
When determining whether we can use "this", make sure to look through
enum contexts (along with block contexts, which we already did). Fixes PR7196. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104444 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--test/SemaCXX/class.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 5e365de695..523b196392 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -305,7 +305,7 @@ void Sema::ActOnEndOfTranslationUnit() {
DeclContext *Sema::getFunctionLevelDeclContext() {
DeclContext *DC = CurContext;
- while (isa<BlockDecl>(DC))
+ while (isa<BlockDecl>(DC) || isa<EnumDecl>(DC))
DC = DC->getParent();
return DC;
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 287f50d63a..b5cecbcf93 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -147,3 +147,15 @@ namespace PR7153 {
ec.member = 0;
}
}
+
+namespace PR7196 {
+ struct A {
+ int a;
+
+ void f() {
+ char i[sizeof(a)];
+ enum { x = sizeof(i) };
+ enum { y = sizeof(a) };
+ }
+ };
+}