]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: add attribute flag_enum [PR81665]
authorJason Merrill <jason@redhat.com>
Thu, 29 Aug 2024 15:09:21 +0000 (11:09 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 6 Sep 2024 01:29:55 +0000 (21:29 -0400)
commit1914ca8791ce4e0ba821e818cb6f86c76afdb6f2
tree980003d03a14846312a2944faddf280a469a48a1
parent3dafb65bb5c31b169dae180e0664dfcaee64afe6
c-family: add attribute flag_enum [PR81665]

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]], introducing
handling of the clang attribute namespace.

PR c++/46457
PR c++/81665

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_flag_enum_attribute): New.
(c_common_gnu_attributes): Add it.
(c_common_clang_attributes, c_common_clang_attribute_table): New.
* c-common.h: Declare c_common_clang_attribute_table.
* c-warn.cc (c_do_switch_warnings): Handle flag_enum.

gcc/c/ChangeLog:

* c-objc-common.h (c_objc_attribute_table): Add
c_common_clang_attribute_table.

gcc/cp/ChangeLog:

* cp-objcp-common.h (cp_objcp_attribute_table): Add
c_common_clang_attribute_table.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-flag-enum-1.c: New test.

gcc/ChangeLog:

* doc/extend.texi: Document flag_enum attribute.
* doc/invoke.texi: Mention flag_enum in -Wswitch.

libstdc++-v3/ChangeLog:

* include/bits/regex_constants.h: Use flag_enum.
gcc/c-family/c-attribs.cc
gcc/c-family/c-common.h
gcc/c-family/c-warn.cc
gcc/c/c-objc-common.h
gcc/cp/cp-objcp-common.h
gcc/doc/extend.texi
gcc/doc/invoke.texi
gcc/testsuite/c-c++-common/attr-flag-enum-1.c [new file with mode: 0644]
libstdc++-v3/include/bits/regex_constants.h