On Wed, Sep 04, 2024 at 08:15:25AM -0400, Jason Merrill wrote:
> Tested x86_64-pc-linux-gnu. Any objections?
Looks good except...
> +/* Attributes also recognized in the clang:: namespace. */
> +const struct attribute_spec c_common_clang_attributes[] = {
> + { "flag_enum", 0, 0, false, true, false, false,
> + handle_flag_enum_attribute, NULL }
> +};
> +
> +const struct scoped_attribute_specs c_common_clang_attribute_table =
> +{
> + "clang", { c_common_clang_attributes }
> +};
> +
> /* Give the specifications for the format attributes, used by C and all
> descendants.
>
> @@ -5017,6 +5031,25 @@ handle_fd_arg_attribute (tree *node, tree name, tree
> args,
> return NULL_TREE;
> }
>
> +/* Handle the "flag_enum" attribute. */
> +
> +static tree
> +handle_flag_enum_attribute (tree *node, tree ARG_UNUSED(name), tree args,
> + int ARG_UNUSED (flags), bool *no_add_attrs)
> +{
> + if (args)
> + warning (OPT_Wattributes, "%qE attribute arguments ignored", name);
You don't need this check I think; if the # of args isn't correct, we
should not get here. Then the goto can...go too.
I see that, like clang++, we accept the attribute on scoped enums too.
Marek