Correct multiversion unsupported target behavior, add a test.

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.  

llvm-svn: 325610
This commit is contained in:
Erich Keane 2018-02-20 18:44:50 +00:00
parent 2cf3769a7e
commit 5e5baf59dd
2 changed files with 14 additions and 0 deletions

View 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;
}

View File

@ -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){}