BlockDeclRefExpr of a dependent type must

be a dependent expression when its is built.

llvm-svn: 108026
This commit is contained in:
Fariborz Jahanian 2010-07-09 22:21:32 +00:00
parent 098039e4f0
commit 4239aa104b
2 changed files with 17 additions and 14 deletions

View File

@ -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<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);
}

View File

@ -22,7 +22,7 @@ template <typename T, typename T1> 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)() = ^{};
}