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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:abcfe1e51c18b14d324586f1d9d50e8238497865

commit r15-4766-gabcfe1e51c18b14d324586f1d9d50e8238497865
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Oct 30 07:59:52 2024 +0100

    c: Add C2Y N3370 - Case range expressions support [PR117021]

    The following patch adds the C2Y N3370 paper support.
    We had the case ranges as a GNU extension for decades, so this patch
    simply:
    1) adds different diagnostics when it is used in C (depending on
flag_isoc2y
       and pedantic and warn_c23_c2y_compat)
    2) emits a pedwarn in C if in a range conversion changes the value of
       the low or high bounds and in that case doesn't emit -Woverflow and
       similar warnings anymore if the pedwarn has been diagnosed
    3) changes the handling of empty ranges both in C and C++; previously
       we just warned but let the values be still looked up in the splay
       tree/entered into it (and let only gimplification throw away those
       empty cases), so e.g. case -6 ... -8: break; case -6: break;
       complained about duplicate case label.  But that actually isn't
       duplicate case label, case -6 ... -8: stands for nothing at all
       and that is how it is treated later on (thrown away)

    2024-10-30  Jakub Jelinek  <ja...@redhat.com>

            PR c/117021
    gcc/c-family/
            * c-common.cc (c_add_case_label): Emit different diagnostics for C
            on case ranges.  Diagnose for C using pedwarn conversions of range
            expressions changing value and don't emit further conversion
            diagnostics if the pedwarn has been diagnosed.  For empty ranges
            bail out after emitting warning, don't add anything into splay
            trees nor add a CASE_LABEL_EXPR.
    gcc/testsuite/
            * gcc.dg/switch-6.c: Expect different diagnostics.  Add -std=gnu23
            to dg-options.
            * gcc.dg/switch-7.c: Expect different diagnostics.  Add -std=c23
            to dg-options.
            * gcc.dg/gnu23-switch-1.c: New test.
            * gcc.dg/gnu23-switch-2.c: New test.
            * gcc.dg/c23-switch-1.c: New test.
            * gcc.dg/c2y-switch-1.c: New test.
            * gcc.dg/c2y-switch-2.c: New test.
            * gcc.dg/c2y-switch-3.c: New test.

Reply via email to