https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Florian Weimer from comment #4)
> For retain, something along these lines might work:
> 
> diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
> index c1f652d1dc9..cdae464ab8a 100644
> --- a/gcc/c-family/c-attribs.c
> +++ b/gcc/c-family/c-attribs.c
> @@ -329,8 +329,10 @@ const struct attribute_spec c_common_attribute_table[] =
>                               handle_used_attribute, NULL },
>    { "unused",                 0, 0, false, false, false, false,
>                               handle_unused_attribute, NULL },
> +#if SUPPORTS_SHF_GNU_RETAIN
>    { "retain",                 0, 0, true,  false, false, false,
>                               handle_retain_attribute, NULL },
> +#endif
>    { "externally_visible",     0, 0, true,  false, false, false,
>                               handle_externally_visible_attribute, NULL },
>    { "no_reorder",            0, 0, true, false, false, false,
> 
> In other cases, it's more difficult because those are subtarget-dependent.

Doing the above would "fix" __has_attribute, but on the other side would mean
the compiler would not know how many and what kind of operands the attribute
has, whether it is for function declarations, other declarations, types or what
etc., so for invalid code it would have inconsistent diagnostics.

Reply via email to