Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-06 Thread Jonathan Wakely
On Fri, 6 Sept 2024 at 20:17, Jason Merrill wrote: > > On 9/6/24 8:56 AM, Jonathan Wakely wrote: > > On 05/09/24 21:44 -0400, Jason Merrill wrote: > >> On 9/4/24 11:02 AM, Marek Polacek wrote: > +handle_flag_enum_attribute (tree *node, tree ARG_UNUSED(name), tree > args, > +

Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-06 Thread Jason Merrill
On 9/6/24 8:56 AM, Jonathan Wakely wrote: On 05/09/24 21:44 -0400, Jason Merrill wrote: On 9/4/24 11:02 AM, Marek Polacek wrote: +handle_flag_enum_attribute (tree *node, tree ARG_UNUSED(name), tree args, +    int ARG_UNUSED (flags), bool *no_add_attrs) +{ +  if (args) +    warning

Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-06 Thread Jonathan Wakely
On 05/09/24 21:44 -0400, Jason Merrill wrote: On 9/4/24 11:02 AM, Marek Polacek wrote: +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

Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-05 Thread Jason Merrill
On 9/4/24 11:02 AM, Marek Polacek wrote: +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

Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-04 Thread Eric Gallager
On Wed, Sep 4, 2024 at 8:18 AM Jason Merrill wrote: > > Tested x86_64-pc-linux-gnu. Any objections? > > -- 8< -- > > Several PRs complain about -Wswitch warning about a case for a bitwise > combination of enumerators. Clang has an attribute flag_enum to prevent > this; let's adopt that approach

Re: [PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-04 Thread Marek Polacek
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, fal

[PATCH RFC] c-family: add attribute flag_enum [PR46457]

2024-09-04 Thread Jason Merrill
Tested x86_64-pc-linux-gnu. Any objections? -- 8< -- Several PRs complain about -Wswitch warning about a case for a bitwise combination of enumerators. Clang has an attribute flag_enum to prevent this; let's adopt that approach as well. This also recognizes the attribute as [[clang::flag_enum]