Author: erichkeane Date: Tue Feb 20 10:44:50 2018 New Revision: 325610 URL: http://llvm.org/viewvc/llvm-project?rev=325610&view=rev Log: 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. Added: cfe/trunk/test/Sema/attr-target-unsupported.c Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325610&r1=325609&r2=325610&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 20 10:44:50 2018 @@ -9365,6 +9365,7 @@ static bool CheckMultiVersionFunction(Se } 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(Se 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; } Added: cfe/trunk/test/Sema/attr-target-unsupported.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-target-unsupported.c?rev=325610&view=auto ============================================================================== --- cfe/trunk/test/Sema/attr-target-unsupported.c (added) +++ cfe/trunk/test/Sema/attr-target-unsupported.c Tue Feb 20 10:44:50 2018 @@ -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){} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits