r341833 - Prevent cpu-specific/cpu-dispatch from giong on a lambda.
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 07:31:56 PDT 2018
Author: erichkeane
Date: Mon Sep 10 07:31:56 2018
New Revision: 341833
URL: http://llvm.org/viewvc/llvm-project?rev=341833&view=rev
Log:
Prevent cpu-specific/cpu-dispatch from giong on a lambda.
It is non-sensical to use cpu-specific/cpu-dispatch multiversioning
on a lambda, so prevent it when trying to add the attribute.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341833&r1=341832&r2=341833&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Sep 10 07:31:56 2018
@@ -1842,6 +1842,14 @@ static void handleRestrictAttr(Sema &S,
static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
FunctionDecl *FD = cast<FunctionDecl>(D);
+
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
+ if (MD->getParent()->isLambda()) {
+ S.Diag(AL.getLoc(), diag::err_attribute_dll_lambda) << AL;
+ return;
+ }
+ }
+
if (!checkAttributeAtLeastNumArgs(S, AL, 1))
return;
Modified: cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp?rev=341833&r1=341832&r2=341833&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp Mon Sep 10 07:31:56 2018
@@ -109,3 +109,6 @@ int __attribute__((cpu_specific(sandybri
// Ensure Cpp Spelling works.
[[clang::cpu_specific(ivybridge,atom)]] int CppSpelling(){}
+
+// expected-error at +1 {{lambda cannot be declared 'cpu_dispatch'}}
+auto x = []() __attribute__((cpu_dispatch(atom))) {};
More information about the cfe-commits
mailing list