]> granicus.if.org Git - clang/commitdiff
Correct multiversion unsupported target behavior, add a test.
authorErich Keane <erich.keane@intel.com>
Tue, 20 Feb 2018 18:44:50 +0000 (18:44 +0000)
committerErich Keane <erich.keane@intel.com>
Tue, 20 Feb 2018 18:44:50 +0000 (18:44 +0000)
Multiversioning SEMA failed to set the declaration as invalid on unsupported
targets.  This patch does that.

Additionally, I noticed that there is no test to validate this error message.
This patch adds one, and uses 'mips' as the test architecture.

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

lib/Sema/SemaDecl.cpp
test/Sema/attr-target-unsupported.c [new file with mode: 0644]

index 7d7b274b81536b60d6a9f6451269adc26f8e5415..ab50b43db240e097c89aaaf8600728495ffd9dc6 100644 (file)
@@ -9365,6 +9365,7 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
       }
       if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
         S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
+        NewFD->setInvalidDecl();
         return true;
       }
 
@@ -9407,6 +9408,7 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
     if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
       S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
       S.Diag(OldFD->getLocation(), diag::note_previous_declaration);
+      NewFD->setInvalidDecl();
       return true;
     }
 
diff --git a/test/Sema/attr-target-unsupported.c b/test/Sema/attr-target-unsupported.c
new file mode 100644 (file)
index 0000000..8e23fcc
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu  -fsyntax-only -verify %s
+
+void __attribute__((target("arch=mips1")))
+foo(void) {}
+// expected-error@+3 {{function multiversioning is not supported on the current target}}
+// expected-note@-2 {{previous declaration is here}}
+void __attribute__((target("arch=mips2")))
+foo(void) {}
+
+// expected-error@+2 {{function multiversioning is not supported on the current target}}
+void __attribute__((target("default")))
+bar(void){}