[cfe-commits] r69306 - in /cfe/trunk: lib/AST/Expr.cpp lib/AST/ExprConstant.cpp test/Sema/block-literal.c

Steve Naroff snaroff at apple.com
Thu Apr 16 12:02:58 PDT 2009


Author: snaroff
Date: Thu Apr 16 14:02:57 2009
New Revision: 69306

URL: http://llvm.org/viewvc/llvm-project?rev=69306&view=rev
Log:
Fix <rdar://problem/6765383> clang-6: clang does not appear to support declaring a static Block 'const'.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/Sema/block-literal.c

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=69306&r1=69305&r2=69306&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Apr 16 14:02:57 2009
@@ -854,6 +854,8 @@
   switch (getStmtClass()) {
   default:
     return false;
+  case BlockExprClass:
+    return true;
   case ParenExprClass:
     return cast<ParenExpr>(this)->getSubExpr()->hasGlobalStorage();
   case ImplicitCastExprClass:

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=69306&r1=69305&r2=69306&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr 16 14:02:57 2009
@@ -156,6 +156,7 @@
 
   APValue VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
   APValue VisitDeclRefExpr(DeclRefExpr *E);
+  APValue VisitBlockExpr(BlockExpr *E);
   APValue VisitPredefinedExpr(PredefinedExpr *E) { return APValue(E, 0); }
   APValue VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
   APValue VisitMemberExpr(MemberExpr *E);
@@ -184,6 +185,14 @@
   return APValue(E, 0); 
 }
 
+APValue LValueExprEvaluator::VisitBlockExpr(BlockExpr *E)
+{ 
+  if (E->hasBlockDeclRefExprs())
+    return APValue();
+    
+  return APValue(E, 0);
+}
+
 APValue LValueExprEvaluator::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
   if (E->isFileScope())
     return APValue(E, 0);
@@ -373,6 +382,7 @@
   }
 
   if (SubExpr->getType()->isFunctionType() ||
+      SubExpr->getType()->isBlockPointerType() ||
       SubExpr->getType()->isArrayType()) {
     APValue Result;
     if (EvaluateLValue(SubExpr, Result, Info))

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

==============================================================================
--- cfe/trunk/test/Sema/block-literal.c (original)
+++ cfe/trunk/test/Sema/block-literal.c Thu Apr 16 14:02:57 2009
@@ -81,6 +81,12 @@
 static int global_x = 10;
 void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
 
+typedef void (^void_block_t)(void);
+
+static const void_block_t myBlock = ^{ };
+
+static const void_block_t myBlock2 = ^ void(void) { }; 
+
 #if 0
 // Old syntax. FIXME: convert/test.
 void test_byref() {





More information about the cfe-commits mailing list