From b9e9dc5e89cc85e761af8c40254352df6b751a84 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 5 Dec 2014 18:03:58 +0000 Subject: Workaround attribute ordering issue with kernel only attributes Placing the attribute after the kernel keyword would incorrectly reject the attribute, so use the smae workaround that other kernel only attributes use. Also add a FIXME because there are two different phrasings now for the same error, althoug amdgpu_num_[sv]gpr uses a consistent one. llvm-svn: 223490 --- clang/lib/Sema/SemaDeclAttr.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'clang/lib/Sema/SemaDeclAttr.cpp') diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index af7cf5713de..ffb8b77a7d0 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4762,6 +4762,8 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, if (!D->hasAttr()) { // These attributes cannot be applied to a non-kernel function. if (Attr *A = D->getAttr()) { + // FIXME: This emits a different error message than + // diag::err_attribute_wrong_decl_type + ExpectedKernelFunction. Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; D->setInvalidDecl(); } else if (Attr *A = D->getAttr()) { @@ -4770,6 +4772,14 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, } else if (Attr *A = D->getAttr()) { Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; D->setInvalidDecl(); + } else if (Attr *A = D->getAttr()) { + Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) + << A << ExpectedKernelFunction; + D->setInvalidDecl(); + } else if (Attr *A = D->getAttr()) { + Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) + << A << ExpectedKernelFunction; + D->setInvalidDecl(); } } } -- cgit v1.2.3