]> granicus.if.org Git - clang/commitdiff
Fix cpu-dispatch MV regression caused by r347812
authorErich Keane <erich.keane@intel.com>
Tue, 15 Jan 2019 17:51:09 +0000 (17:51 +0000)
committerErich Keane <erich.keane@intel.com>
Tue, 15 Jan 2019 17:51:09 +0000 (17:51 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351212 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/attr-cpuspecific.c

index e853180d76a0cb861461ac2e9e2bd533697befb2..23c99d45a78d4d1b8f13890e617968ba59c57d43 100644 (file)
@@ -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;
   }
index d15a65ea1fc550ed21bb034ca2beaae37ec10fc2..e87ad4de752545beb065ca68dfd141ae9a57e3d8 100644 (file)
@@ -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);