https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100643
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The C frontend accepts it when you make the outer function 'int foo(void)'.
When you make the testcase
int foo(void) __attribute__((target("avx")));
int foo(void) __attribute__((target("default")));
int foo(void)
{
return 124;
}
then the C++ frontend rejects it as
t.c:3:5: error: missing 'target' attribute for multi-versioned 'int foo()'
3 | int foo(void)
| ^~~
t.c:2:5: note: previous declaration of 'int foo()'
2 | int foo(void) __attribute__((target("default")));
| ^~~
when you make it
int foo(void)
{
return 124;
}
int foo(void) __attribute__((target("avx")));
int foo(void) __attribute__((target("default")));
it is accepted.