Skip to content

Commit 28f7a2a

Browse files
committed
[TargetVersion] Only enable on RISC-V and AArch64
1 parent 37143fe commit 28f7a2a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,8 @@ def warn_unsupported_target_attribute
32823282
"attribute string; '%select{target|target_clones|target_version}3' "
32833283
"attribute ignored">,
32843284
InGroup<IgnoredAttributes>;
3285+
def err_target_version_unsupported
3286+
: Error<"target_version attribute is not supported in this target">;
32853287
def err_attribute_unsupported
32863288
: Error<"%0 attribute is not supported on targets missing %1;"
32873289
" specify an appropriate -march= or -mcpu=">;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,11 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
30403040
enum FirstParam { Unsupported };
30413041
enum SecondParam { None };
30423042
enum ThirdParam { Target, TargetClones, TargetVersion };
3043+
3044+
if (!Context.getTargetInfo().getTriple().isRISCV() &&
3045+
!Context.getTargetInfo().getTriple().isAArch64())
3046+
return Diag(LiteralLoc, diag::err_target_version_unsupported);
3047+
30433048
llvm::SmallVector<StringRef, 8> Features;
30443049
if (Context.getTargetInfo().getTriple().isRISCV()) {
30453050
llvm::SmallVector<StringRef, 8> AttrStrs;

0 commit comments

Comments
 (0)