diff options
author | Marek Polacek <polacek@redhat.com> | 2022-05-07 16:15:49 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-05-18 10:34:30 -0400 |
commit | 60fdce11dc9e5ddf671b07a3fc6ed70476860b22 (patch) | |
tree | c8f625cb6000e14bf77d49ce48b2683660526034 /gcc/c | |
parent | dfe38b8d5dbfe3dd5209aece4ce2f7a6b303a2f9 (diff) | |
download | gcc-60fdce11dc9e5ddf671b07a3fc6ed70476860b22.zip gcc-60fdce11dc9e5ddf671b07a3fc6ed70476860b22.tar.gz gcc-60fdce11dc9e5ddf671b07a3fc6ed70476860b22.tar.bz2 |
c, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]
This PR complains that we emit the "enumeration value not handled in
switch" warning even though the enumerator was marked with the
[[maybe_unused]] attribute.
I couldn't just check TREE_USED, because the enumerator could have been
used earlier in the function, which doesn't play well with the
c_do_switch_warnings warning. Instead, I had to check the attributes on
the CONST_DECL. This is easy since the TYPE_VALUES of an enum type are
now consistent between C and C++, both of which store the CONST_DECL in
its TREE_VALUE.
PR c++/105497
gcc/c-family/ChangeLog:
* c-warn.cc (c_do_switch_warnings): Don't warn about unhandled
enumerator when it was marked with attribute unused.
gcc/testsuite/ChangeLog:
* c-c++-common/Wswitch-1.c: New test.
* g++.dg/warn/Wswitch-4.C: New test.
Diffstat (limited to 'gcc/c')
0 files changed, 0 insertions, 0 deletions