summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2019-01-15 17:51:09 +0000
committerErich Keane <erich.keane@intel.com>2019-01-15 17:51:09 +0000
commite6829a5eb343fdc6cdf9e7e5a63ad0e810509d29 (patch)
treeda07c9c206576d2c0be17535665ef943e1d1941a /clang
parentdee001207e0985d9ad17fee765fc32b6ad4fa1e3 (diff)
downloadbcm5719-llvm-e6829a5eb343fdc6cdf9e7e5a63ad0e810509d29.tar.gz
bcm5719-llvm-e6829a5eb343fdc6cdf9e7e5a63ad0e810509d29.zip
Fix cpu-dispatch MV regression caused by r347812
r347812 permitted forward declarations for cpu-dispatch functions, which are occassionally useful as exposition in header files. However, this inadvertently permitted this function to become multiversioned after a usage. This patch ensures that the "CausesMV" checks are still run in the forward-declaration case. Change-Id: Icb6f975a2d068f088b89e3bbe26cf1d24f5a972c llvm-svn: 351212
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
-rw-r--r--clang/test/Sema/attr-cpuspecific.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e853180d76a..23c99d45a78 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9816,7 +9816,8 @@ static bool CheckMultiVersionAdditionalDecl(
return true;
}
- if (CheckMultiVersionAdditionalRules(S, OldFD, NewFD, false, NewMVType)) {
+ if (CheckMultiVersionAdditionalRules(S, OldFD, NewFD,
+ !OldFD->isMultiVersion(), NewMVType)) {
NewFD->setInvalidDecl();
return true;
}
diff --git a/clang/test/Sema/attr-cpuspecific.c b/clang/test/Sema/attr-cpuspecific.c
index d15a65ea1fc..e87ad4de752 100644
--- a/clang/test/Sema/attr-cpuspecific.c
+++ b/clang/test/Sema/attr-cpuspecific.c
@@ -40,6 +40,14 @@ int __attribute__((cpu_dispatch(atom))) redecl2(void) { }
int allow_fwd_decl(void);
int __attribute__((cpu_dispatch(atom))) allow_fwd_decl(void) {}
+int allow_fwd_decl2(void);
+void use_fwd_decl(void) {
+ allow_fwd_decl2();
+}
+// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
+int __attribute__((cpu_dispatch(atom))) allow_fwd_decl2(void) {}
+
+
int __attribute__((cpu_specific(atom))) redecl4(void);
// expected-error@+1 {{function declaration is missing 'cpu_specific' or 'cpu_dispatch' attribute in a multiversioned function}}
int redecl4(void);
OpenPOWER on IntegriCloud