c: c++: Add target_[version/clones] to decl diagnostics formatting.
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.
This also requires making maybe_print_whitespace available to c++ code so
we can control if whitespace is needed cosistantly between c and c++
diagnostics.
After this change diagnostics look like:
c:
```
test.c:6:8: error: redefinition of ‘foo [[target_version("sve")]]’
6 | float foo () {return 1;}
| ^~~
test.c:3:8: note: previous definition of ‘foo [[target_version("sve")]]’ with type ‘float(void)’
3 | float foo () {return 2;}
| ^~~
test.c:12:8: error: redefinition of ‘bar [[target_clones("sve")]]’
12 | float bar () {return 1;}
| ^~~
test.c:9:8: note: previous definition of ‘bar [[target_clones("sve")]]’ with type ‘float(void)’
9 | float bar () {return 2;}
| ^~~
```
c++:
```
test.cpp:6:8: error: redefinition of ‘float foo [[target_version("sve")]] ()’
6 | float foo () {return 1;}
| ^~~
test.cpp:3:8: note: ‘float foo [[target_version("sve")]] ()’ previously defined here
3 | float foo () {return 2;}
| ^~~
test.cpp:12:8: error: redefinition of ‘float bar [[target_clones("sve")]] ()’
12 | float bar () {return 1;}
| ^~~
test.cpp:9:8: note: ‘float bar [[target_clones("sve")]] ()’ previously defined here
9 | float bar () {return 2;}
| ^~~
```
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.
(pp_c_maybe_whitespace): Move to c-pretty-print.h.
* c-pretty-print.h (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
(pp_c_maybe_whitespace): Moved here from c-pretty-print.cc.
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.
(pp_cxx_maybe_whitespace): Ditto.
* error.cc (dump_function_decl): Add printing of target_clone and
target_version in decl diagnostics.