Skip to content

Commit 7d8d51e

Browse files
BeMgAaronBallman
andauthored
Recommit "[TargetVersion] Only enable on RISC-V and AArch64" (#117110)" (#117128)
Remain InheritableAttr to avoid the warning `TypePrinter.cpp:1953:10: warning: enumeration value ‘TargetVersion’ not handled in switch` origin messenge [TargetVersion] Only enable on RISC-V and AArch64 (#115991) Address #115000. This patch constrains the target_version feature to work only on RISC-V and AArch64 to prevent crashes in Clang. Co-authored-by: Aaron Ballman <[email protected]>
1 parent 2b5e2d7 commit 7d8d51e

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ Attribute Changes in Clang
471471
- Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
472472
used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
473473

474+
- The ``target_version`` attribute is now only supported for AArch64 and RISC-V architectures.
475+
474476
Improvements to Clang's diagnostics
475477
-----------------------------------
476478

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ def Target : InheritableAttr {
32973297
}];
32983298
}
32993299

3300-
def TargetVersion : InheritableAttr {
3300+
def TargetVersion : InheritableAttr, TargetSpecificAttr<TargetArch<!listconcat(TargetAArch64.Arches, TargetRISCV.Arches)>> {
33013301
let Spellings = [GCC<"target_version">];
33023302
let Args = [StringArgument<"NamesStr">];
33033303
let Subjects = SubjectList<[Function], ErrorDiag>;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
2+
3+
//expected-warning@+1 {{unknown attribute 'target_version' ignored}}
4+
int __attribute__((target_version("aes"))) foo(void) { return 3; }

0 commit comments

Comments
 (0)