When determining whether we can use "this", make sure to look through

enum contexts (along with block contexts, which we already did). Fixes
PR7196.

llvm-svn: 104444
This commit is contained in:
Douglas Gregor 2010-05-22 16:25:05 +00:00
parent 959d5a0cbd
commit 0c6f539564
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -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) };
}
};
}