summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2018-09-10 14:31:56 +0000
committerErich Keane <erich.keane@intel.com>2018-09-10 14:31:56 +0000
commit659c871a1b47836bb0b02f63124bc35e00990f1c (patch)
treeb1513f29a400681ecc1ed6a0fb4c9e51e50cd14b
parent5faf8a3d84a7e172f20d81d33b4bae67108b5090 (diff)
downloadbcm5719-llvm-659c871a1b47836bb0b02f63124bc35e00990f1c.tar.gz
bcm5719-llvm-659c871a1b47836bb0b02f63124bc35e00990f1c.zip
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. llvm-svn: 341833
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp8
-rw-r--r--clang/test/SemaCXX/attr-cpuspecific.cpp3
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 65c636b94ea..db5df4db802 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1842,6 +1842,14 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
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;
diff --git a/clang/test/SemaCXX/attr-cpuspecific.cpp b/clang/test/SemaCXX/attr-cpuspecific.cpp
index a881b6c4e2b..7ec8c6cd0ce 100644
--- a/clang/test/SemaCXX/attr-cpuspecific.cpp
+++ b/clang/test/SemaCXX/attr-cpuspecific.cpp
@@ -109,3 +109,6 @@ int __attribute__((cpu_specific(sandybridge))) BadOutOfLine::foo(int) { return 1
// Ensure Cpp Spelling works.
[[clang::cpu_specific(ivybridge,atom)]] int CppSpelling(){}
+
+// expected-error@+1 {{lambda cannot be declared 'cpu_dispatch'}}
+auto x = []() __attribute__((cpu_dispatch(atom))) {};
OpenPOWER on IntegriCloud