On 09/07/2025 18:00, Jason Merrill wrote:
On 5/29/25 8:52 AM, Alfie Richards wrote:
Adds the target_version and target_clones attributes to diagnostic
messages
for target_version semantics.
This is because the target_version/target_clones attributes affect the
identity
of the decls, so need to be represented in diagnostics for them.
After this change diagnostics look like:
```
test.c:5:7: error: redefinition of ‘[[target_version("sve")]] foo’
5 | float foo () {return 2;}
| ^~~
test.c:2:7: note: previous definition of ‘[[target_version("sve")]]
foo’ with type ‘float(void)’
2 | float foo () {return 1;}
```
It would be better to print this information after the identifier, to
match standard attribute syntax; attributes generally appertain to the
thing immediately to their left. Except attributes at the very
beginning of the declaration, but that doesn't apply here because we
only see the identifier.
Thanks Jason that makes sense.
This patch was approved in the V6 series, I'll re-roll this patch and
send to you for re-approval if that alright?
Any feedback on the `[PATCH v6 12/19] c++: Refactor FMV frontend
conflict and merging logic and hooks` would also be great as I'm unsure
about some of the C++ front end choices I made.
This only affects targets which use target_version (aarch64 and riscv).
gcc/c-family/ChangeLog:
* c-pretty-print.cc (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
* c-pretty-print.h (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
gcc/c/ChangeLog:
* c-objc-common.cc (c_tree_printer): Add printing of target_clone and
target_version in decl diagnostics.
gcc/cp/ChangeLog:
* cxx-pretty-print.h (pp_cxx_function_target_version): New macro.
(pp_cxx_function_target_clones): Ditto.
* error.cc (dump_function_decl): Add printing of target_clone and
target_version in decl diagnostics.