summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-12-13 16:15:28 +0000
committerJoey Gouly <joey.gouly@arm.com>2013-12-13 16:15:28 +0000
commit2cd9db1cefbbaea422f195a76ad74474b410ce3c (patch)
tree3e7b1c5aa4b6d4f4cda285e32330bd8b02204ec5 /clang/lib/Sema/SemaDeclAttr.cpp
parent984c9d86cbc957b232e436e873fc47fcde5b57cc (diff)
downloadbcm5719-llvm-2cd9db1cefbbaea422f195a76ad74474b410ce3c.tar.gz
bcm5719-llvm-2cd9db1cefbbaea422f195a76ad74474b410ce3c.zip
[OpenCL] Produce an error when the work group and vec type hint attributes
are used on non-kernel functions. Reviewed by Aaron over IRC! llvm-svn: 197243
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index f96add14826..5e9bd2cf49b 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4217,6 +4217,7 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
for (const AttributeList* l = AttrList; l; l = l->getNext())
ProcessDeclAttribute(*this, S, D, *l, IncludeCXX11Attributes);
+ // FIXME: We should be able to handle these cases in TableGen.
// GCC accepts
// static int a9 __attribute__((weakref));
// but that looks really pointless. We reject it.
@@ -4226,6 +4227,24 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
D->dropAttr<WeakRefAttr>();
return;
}
+
+ if (!D->hasAttr<OpenCLKernelAttr>()) {
+ // These attributes cannot be applied to a non-kernel function.
+ if (D->hasAttr<ReqdWorkGroupSizeAttr>()) {
+ Diag(D->getLocation(), diag::err_opencl_kernel_attr)
+ << "reqd_work_group_size";
+ D->setInvalidDecl();
+ }
+ if (D->hasAttr<WorkGroupSizeHintAttr>()) {
+ Diag(D->getLocation(), diag::err_opencl_kernel_attr)
+ << "work_group_size_hint";
+ D->setInvalidDecl();
+ }
+ if (D->hasAttr<VecTypeHintAttr>()) {
+ Diag(D->getLocation(), diag::err_opencl_kernel_attr) << "vec_type_hint";
+ D->setInvalidDecl();
+ }
+ }
}
// Annotation attributes are the only attributes allowed after an access
OpenPOWER on IntegriCloud