diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-02-04 23:05:15 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-02-04 23:05:15 +0100 |
commit | 6f9fdf4db2c68f482ec4ff3cadaea0537a4b13e1 (patch) | |
tree | abbbeb9e68d3bc70e43d55d15b23db2b78adbf38 /gcc/cp/semantics.c | |
parent | 79109502a02948f16653b44b434b8b4ef8aebd54 (diff) | |
download | gcc-6f9fdf4db2c68f482ec4ff3cadaea0537a4b13e1.zip gcc-6f9fdf4db2c68f482ec4ff3cadaea0537a4b13e1.tar.gz gcc-6f9fdf4db2c68f482ec4ff3cadaea0537a4b13e1.tar.bz2 |
PR c/4475, c++/3780:
* c-common.def (SWITCH_STMT): Add SWITCH_TYPE operand.
* c-common.h (SWITCH_TYPE): Define.
* c-typeck.c (c_start_case): Set SWITCH_TYPE.
* stmt.c (all_cases_count): Set lastval to thisval at end of loop.
Rename spareness variable to sparseness.
(expand_end_case_type): Renamed from expand_end_case, use orig_type
if non-NULL instead of TREE_TYPE (orig_index).
* tree.h (expand_end_case_type): Renamed from expand_end_case.
(expand_end_case): Define using expand_end_case_type.
* c-semantics.c (genrtl_switch_stmt): Pass SWITCH_TYPE
to expand_end_case_type.
* doc/c-tree.texi (SWITCH_STMT): Document SWITCH_TYPE.
* semantics.c (begin_switch_stmt): Clear SWITCH_TYPE.
(finish_switch_cond): Set SWITCH_TYPE.
* gcc.dg/Wswitch.c: Fix typos. Don't return unconditionally
before all tests. Move warning one line above to match where it
C frontend emits.
* gcc.dg/Wswitch-2.c: New test.
* g++.dg/warn/Wswitch-1.C: New test.
* g++.dg/warn/Wswitch-2.C: New test.
From-SVN: r49497
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cdc1178..c344a30 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -500,7 +500,7 @@ tree begin_switch_stmt () { tree r; - r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE); + r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE); add_stmt (r); do_pushlevel (); return r; @@ -513,6 +513,7 @@ finish_switch_cond (cond, switch_stmt) tree cond; tree switch_stmt; { + tree orig_type = NULL; if (!processing_template_decl) { tree type; @@ -525,6 +526,7 @@ finish_switch_cond (cond, switch_stmt) error ("switch quantity not an integer"); cond = error_mark_node; } + orig_type = TREE_TYPE (cond); if (cond != error_mark_node) { cond = default_conversion (cond); @@ -542,6 +544,7 @@ finish_switch_cond (cond, switch_stmt) cond = index; } FINISH_COND (cond, switch_stmt, SWITCH_COND (switch_stmt)); + SWITCH_TYPE (switch_stmt) = orig_type; push_switch (switch_stmt); } |