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
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 07ce6b0..9a0d0ac 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -432,10 +432,11 @@
// 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,