diff options
author | Chris Lattner <sabre@nondot.org> | 2008-09-28 05:30:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-09-28 05:30:26 +0000 |
commit | f7037b1c3be02fdc901862641d93118ea812e5f8 (patch) | |
tree | 9684fc03a0905f4306f1b27f89b6922817ebd350 | |
parent | 81983111dfa43e5f6b21b221c959586a6a766e76 (diff) |
Fix rdar://6251437, references to enum constant decls in a block
don't need a BlockDeclRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56766 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 5 | ||||
-rw-r--r-- | test/Sema/block-misc.c | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 07ce6b0b2f..9a0d0aca0e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -432,10 +432,11 @@ Sema::ExprResult Sema::ActOnIdentifierExpr(Scope *S, SourceLocation Loc, // within the block, create a normal DeclRefExpr. // // FIXME: This will create BlockDeclRefExprs for global variables, - // function references, enums constants, etc which is suboptimal :) and breaks + // function references, etc which is suboptimal :) and breaks // things like "integer constant expression" tests. // - if (!CurBlock || DeclDefinedWithinScope(VD, CurBlock->TheScope, S)) + if (!CurBlock || DeclDefinedWithinScope(VD, CurBlock->TheScope, S) || + isa<EnumConstantDecl>(VD)) return new DeclRefExpr(VD, VD->getType(), Loc); // If we are in a block and the variable is outside the current block, diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 92632f3aaa..77de4a6c9e 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -48,3 +48,17 @@ int test3() { char *^ y; // expected-error {{block pointer to non-function type is invalid}} } + + +enum {NSBIRLazilyAllocated = 0}; + +int test4(int argc) { // rdar://6251437 + ^{ + switch (argc) { + case NSBIRLazilyAllocated: // is an integer constant expression. + default: + break; + } + }(); + return 0; +} |