[cfe-commits] r108026 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGenCXX/instantiate-blocks.cpp

Fariborz Jahanian fjahanian at apple.com
Fri Jul 9 15:21:32 PDT 2010


Author: fjahanian
Date: Fri Jul  9 17:21:32 2010
New Revision: 108026

URL: http://llvm.org/viewvc/llvm-project?rev=108026&view=rev
Log:
BlockDeclRefExpr of a dependent type must
be a dependent expression when its is built.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=108026&r1=108025&r2=108026&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul  9 17:21:32 2010
@@ -1748,22 +1748,25 @@
                                                             ExprTy, Loc, false,
                                                             constAdded);
     QualType T = VD->getType();
-    if (getLangOptions().CPlusPlus && !T->isDependentType() &&
-        !T->isReferenceType()) {
-      Expr *E = new (Context) 
-                  DeclRefExpr(const_cast<ValueDecl*>(BDRE->getDecl()), T,
-                                         SourceLocation());
+    if (getLangOptions().CPlusPlus) {
+      if (!T->isDependentType() && !T->isReferenceType()) {
+        Expr *E = new (Context) 
+                    DeclRefExpr(const_cast<ValueDecl*>(BDRE->getDecl()), T,
+                                          SourceLocation());
       
-      OwningExprResult Res = PerformCopyInitialization(
-                      InitializedEntity::InitializeBlock(VD->getLocation(), 
+        OwningExprResult Res = PerformCopyInitialization(
+                          InitializedEntity::InitializeBlock(VD->getLocation(), 
                                                          T, false),
-                      SourceLocation(),
-                      Owned(E));
-      if (!Res.isInvalid()) {
-        Res = MaybeCreateCXXExprWithTemporaries(move(Res));
-        Expr *Init = Res.takeAs<Expr>();
-        BDRE->setCopyConstructorExpr(Init);
+                                                         SourceLocation(),
+                                                         Owned(E));
+        if (!Res.isInvalid()) {
+          Res = MaybeCreateCXXExprWithTemporaries(move(Res));
+          Expr *Init = Res.takeAs<Expr>();
+          BDRE->setCopyConstructorExpr(Init);
+        }
       }
+      else if (T->isDependentType())
+        BDRE->setTypeDependent(true);
     }
     return Owned(BDRE);
   }

Modified: cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp?rev=108026&r1=108025&r2=108026&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/instantiate-blocks.cpp Fri Jul  9 17:21:32 2010
@@ -22,7 +22,7 @@
 
     T1 (^block)(char, T, T1, double) =  
 	^ T1 (char ch, T arg, T1 arg2, double d1) { byref_block_arg = arg2;
-           					    return byref_block_arg + arg; };
+           					    return byref_block_arg + block_arg + arg; };
 
     void (^block2)() = ^{};
 }





More information about the cfe-commits mailing list