From: Fariborz Jahanian Date: Fri, 9 Jul 2010 22:21:32 +0000 (+0000) Subject: BlockDeclRefExpr of a dependent type must X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=833f42e32754515bc108b9b1ccccc6e373915a6c;p=clang BlockDeclRefExpr of a dependent type must be a dependent expression when its is built. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108026 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index dfa472cc26..a9a3b2c8ce 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1748,22 +1748,25 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, ExprTy, Loc, false, constAdded); QualType T = VD->getType(); - if (getLangOptions().CPlusPlus && !T->isDependentType() && - !T->isReferenceType()) { - Expr *E = new (Context) - DeclRefExpr(const_cast(BDRE->getDecl()), T, - SourceLocation()); + if (getLangOptions().CPlusPlus) { + if (!T->isDependentType() && !T->isReferenceType()) { + Expr *E = new (Context) + DeclRefExpr(const_cast(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(); - BDRE->setCopyConstructorExpr(Init); + SourceLocation(), + Owned(E)); + if (!Res.isInvalid()) { + Res = MaybeCreateCXXExprWithTemporaries(move(Res)); + Expr *Init = Res.takeAs(); + BDRE->setCopyConstructorExpr(Init); + } } + else if (T->isDependentType()) + BDRE->setTypeDependent(true); } return Owned(BDRE); } diff --git a/test/CodeGenCXX/instantiate-blocks.cpp b/test/CodeGenCXX/instantiate-blocks.cpp index 7246f69e8e..c8f897de82 100644 --- a/test/CodeGenCXX/instantiate-blocks.cpp +++ b/test/CodeGenCXX/instantiate-blocks.cpp @@ -22,7 +22,7 @@ template void foo(T t, T1 r) 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)() = ^{}; }