[OpenCL] Add Sema checks for OpenCL 2.0 block

Summary:
Add Sema checks for opencl 2.0 new features: Block.
This patch is partitioned from http://reviews.llvm.org/D16047

Reviewers: Anastasia

Subscribers: pekka.jaaskelainen, cfe-commits

Differential Revision: http://reviews.llvm.org/D17436

llvm-svn: 261719
This commit is contained in:
Xiuli Pan
2016-02-24 04:29:36 +00:00
parent 74a1fc6f87
commit 89307aa3e9
5 changed files with 85 additions and 0 deletions

View File

@@ -6708,6 +6708,19 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
NewVD->setInvalidDecl();
return;
}
// OpenCL v2.0 s6.12.5 - Blocks with variadic arguments are not supported.
if (LangOpts.OpenCL && T->isBlockPointerType()) {
const BlockPointerType *BlkTy = T->getAs<BlockPointerType>();
const FunctionProtoType *FTy =
BlkTy->getPointeeType()->getAs<FunctionProtoType>();
if (FTy->isVariadic()) {
Diag(NewVD->getLocation(), diag::err_opencl_block_proto_variadic)
<< T << NewVD->getSourceRange();
NewVD->setInvalidDecl();
return;
}
}
}
/// \brief Perform semantic checking on a newly-created variable