Skip to content

Commit 5f7a3eb

Browse files
committed
Using the TargetSpecificAttr instead of InheritableAttr
1 parent 659b628 commit 5f7a3eb

File tree

4 files changed

+2
-8
lines changed

4 files changed

+2
-8
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,7 @@ def Target : InheritableAttr {
32633263
}];
32643264
}
32653265

3266-
def TargetVersion : InheritableAttr {
3266+
def TargetVersion : DeclOrTypeAttr, TargetSpecificAttr<TargetArch<!listconcat(TargetAArch64.Arches, TargetRISCV.Arches)>> {
32673267
let Spellings = [GCC<"target_version">];
32683268
let Args = [StringArgument<"NamesStr">];
32693269
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,8 +3282,6 @@ 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 on this target">;
32873285
def err_attribute_unsupported
32883286
: Error<"%0 attribute is not supported on targets missing %1;"
32893287
" specify an appropriate -march= or -mcpu=">;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,10 +3041,6 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
30413041
enum SecondParam { None };
30423042
enum ThirdParam { Target, TargetClones, TargetVersion };
30433043

3044-
if (!Context.getTargetInfo().getTriple().isRISCV() &&
3045-
!Context.getTargetInfo().getTriple().isAArch64())
3046-
return Diag(LiteralLoc, diag::err_target_version_unsupported);
3047-
30483044
llvm::SmallVector<StringRef, 8> Features;
30493045
if (Context.getTargetInfo().getTriple().isRISCV()) {
30503046
llvm::SmallVector<StringRef, 8> AttrStrs;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
22

3-
//expected-error@+1 {{target_version attribute is not supported on this target}}
3+
//expected-warning@+1 {{unknown attribute 'target_version' ignored}}
44
int __attribute__((target_version("aes"))) foo(void) { return 3; }

0 commit comments

Comments
 (0)