https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105497

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:60fdce11dc9e5ddf671b07a3fc6ed70476860b22

commit r13-622-g60fdce11dc9e5ddf671b07a3fc6ed70476860b22
Author: Marek Polacek <pola...@redhat.com>
Date:   Sat May 7 16:15:49 2022 -0400

    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.
  • [Bug c++/105497] -Wswitch ignor... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to