[cfe-commits] r56766 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/block-misc.c

Chris Lattner sabre at nondot.org
Sat Sep 27 22:30:26 PDT 2008


Author: lattner
Date: Sun Sep 28 00:30:26 2008
New Revision: 56766

URL: http://llvm.org/viewvc/llvm-project?rev=56766&view=rev
Log:
Fix rdar://6251437, references to enum constant decls in a block
don't need a BlockDeclRefExpr.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/block-misc.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=56766&r1=56765&r2=56766&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Sep 28 00:30:26 2008
@@ -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,

Modified: cfe/trunk/test/Sema/block-misc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=56766&r1=56765&r2=56766&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-misc.c (original)
+++ cfe/trunk/test/Sema/block-misc.c Sun Sep 28 00:30:26 2008
@@ -48,3 +48,17 @@
 	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;
+}





More information about the cfe-commits mailing list