diff options
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/Sema/attr-target-unsupported.c | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7d7b274b815..ab50b43db24 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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/clang/test/Sema/attr-target-unsupported.c b/clang/test/Sema/attr-target-unsupported.c new file mode 100644 index 00000000000..8e23fcc17eb --- /dev/null +++ b/clang/test/Sema/attr-target-unsupported.c @@ -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){} |