re PR c/89888 (When switch controlling expression is promoted from type narrower...
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Apr 2019 11:56:07 +0000 (13:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 19 Apr 2019 11:56:07 +0000 (13:56 +0200)
commitc280b7ee5c5dfcc1b4ae2c0389987b7b67ec8cf8
treeea24706aa8db720c9a1d2368df12936553d81be8
parent4180490732498b1d7e30eb73abb6a7c934b89256
re PR c/89888 (When switch controlling expression is promoted from type narrower than int, GCC does not diagnose identical cases)

PR c/89888
* c-common.h (c_add_case_label): Remove orig_type and outside_range_p
arguments.
(c_do_switch_warnings): Remove outside_range_p argument.
* c-common.c (check_case_bounds): Removed.
(c_add_case_label): Remove orig_type and outside_range_p arguments.
Don't call check_case_bounds.  Fold low_value as well as high_value.
* c-warn.c (c_do_switch_warnings): Remove outside_range_p argument.
Check for case labels outside of range of original type here and
adjust them.
c/
* c-typeck.c (struct c_switch): Remove outside_range_p member.
(c_start_case): Don't clear it.
(do_case): Adjust c_add_case_label caller.
(c_finish_case): Adjust c_do_switch_warnings caller.
cp/
* decl.c (struct cp_switch): Remove outside_range_p member.
(push_switch): Don't clear it.
(pop_switch): Adjust c_do_switch_warnings caller.
(finish_case_label): Adjust c_add_case_label caller.
testsuite/
* c-c++-common/pr89888.c: New test.
* g++.dg/torture/pr40335.C: Change dg-bogus into dg-warning.
Don't expect -Wswitch-unreachable warning.

From-SVN: r270455
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-warn.c
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr89888.c [new file with mode: 0644]
gcc/testsuite/g++.dg/torture/pr40335.C