diff options
author | Jason Merrill <jason@redhat.com> | 2024-08-29 11:09:21 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-09-05 21:29:55 -0400 |
commit | 1914ca8791ce4e0ba821e818cb6f86c76afdb6f2 (patch) | |
tree | 980003d03a14846312a2944faddf280a469a48a1 /gcc/cp/cp-objcp-common.h | |
parent | 3dafb65bb5c31b169dae180e0664dfcaee64afe6 (diff) | |
download | gcc-1914ca8791ce4e0ba821e818cb6f86c76afdb6f2.zip gcc-1914ca8791ce4e0ba821e818cb6f86c76afdb6f2.tar.gz gcc-1914ca8791ce4e0ba821e818cb6f86c76afdb6f2.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp/cp-objcp-common.h')
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 0e6664c..e9c5ac4 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -128,6 +128,7 @@ static const scoped_attribute_specs *const cp_objcp_attribute_table[] = &std_attribute_table, &cxx_gnu_attribute_table, &c_common_gnu_attribute_table, + &c_common_clang_attribute_table, &c_common_format_attribute_table }; |