diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-10-30 07:59:52 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2024-10-30 07:59:52 +0100 |
commit | abcfe1e51c18b14d324586f1d9d50e8238497865 (patch) | |
tree | f5b95c3417a6aacc46b345bab93f79d6343e8b56 /gcc/function.cc | |
parent | 12086865232382f93081d5564ff44b14bd71341c (diff) | |
download | gcc-abcfe1e51c18b14d324586f1d9d50e8238497865.zip gcc-abcfe1e51c18b14d324586f1d9d50e8238497865.tar.gz gcc-abcfe1e51c18b14d324586f1d9d50e8238497865.tar.bz2 |
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 <jakub@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.
Diffstat (limited to 'gcc/function.cc')
0 files changed, 0 insertions, 0 deletions