diff options
author | Benjamin Chelf <chelf@codesourcery.com> | 2000-07-10 10:56:23 +0000 |
---|---|---|
committer | Ben Chelf <chelf@gcc.gnu.org> | 2000-07-10 03:56:23 -0700 |
commit | 0dfdeca6e06b76d99dfb3150f36c4dd2a501058c (patch) | |
tree | 8641e231837656bb79d18970254d75daaf2bb9f9 /gcc/c-decl.c | |
parent | f12eef581848449cc0099e63b8e2e20f8979e191 (diff) | |
download | gcc-0dfdeca6e06b76d99dfb3150f36c4dd2a501058c.zip gcc-0dfdeca6e06b76d99dfb3150f36c4dd2a501058c.tar.gz gcc-0dfdeca6e06b76d99dfb3150f36c4dd2a501058c.tar.bz2 |
c-common.h (build_stmt): Declare.
2000-07-10 Benjamin Chelf <chelf@codesourcery.com>
* c-common.h (build_stmt): Declare.
(build_continue_stmt): Likewise.
(build_break_stmt): Likewise.
(build_return_stmt): Likewise.
* c-decl.c (do_case): Rewrite to do what previously done in
c-parse.in.
* c-semantics.c (build_stmt): Define.
(build_return_stmt): Likewise.
(build_break_stmt): Likewise.
(build_continue_stmt): Likewise.
(build_case_label): Likewise.
* c-parse.in (BREAK): Change to build tree, then generate RTL.
(CONTINUE): Likewise.
(RETURN): Likewise.
(CASE): Likewise.
(DEFAULT): Likewise.
* c-parse.y: Regenerate.
* c-pasre.c: Likewise.
* cp/semantics.c (finish_for_stmt): Remove call to emit_line_note.
(finish_continue_stmt): Likewise.
(begin_for_stmt): Remove call to note_level_for_for.
(finish_goto_stmt): Change call from build_min_nt
to build_stmt.
(finish_expr_stmt): Likewise.
(begin_if_stmt): Likewise.
(begin_while_stmt): Likewise.
(finish_while_stmt): Likewise.
(finish_return_stmt): Likewise.
(begin_for_stmt): Likewise.
(finish_for_stmt): Likewise.
(finish_break_stmt): Likewise.
(begin_switch_stmt): Likewise.
(finish_case_label): Likewise.
(genrtl_try_block): Likewise.
(begin_try_block): Likewise.
(begin_handler): Likewise.
(begin_compound_stmt): Likewise.
(finish_asm_stmt): Likewise.
(finish_label_stmt): Likewise.
(add_decl_stmt): Likewise.
(finish_subobject): Likewise.
(finish_decl_cleanup): Likewise.
(finish_named_return_value): Likewise.
(setup_vtbl_ptr): Likewise.
(add_scope_stmt): Likewise.
* cp/decl.c (finish_constructor_body): Likewise.
(finish_destructor_body): Likewise.
* cp/optimize.c (copy_body_r): Likewise.
(initialize_inlined_parameters): Likewise.
(declare_return_variable): Likewise.
(expand_call_inline): Likewise.
From-SVN: r34943
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index b2beebf..239bf13 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6841,7 +6841,62 @@ do_case (low_value, high_value) tree low_value; tree high_value; { - abort (); + tree value1 = NULL_TREE, value2 = NULL_TREE, label; + + if (low_value != NULL_TREE) + value1 = check_case_value (low_value); + if (high_value != NULL_TREE) + value2 = check_case_value (high_value); + + label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); + + if (pedantic && (high_value != NULL_TREE)) + pedwarn ("ANSI C forbids case ranges"); + + if (value1 != error_mark_node && value2 != error_mark_node) + { + tree duplicate; + int success; + + if (high_value == NULL_TREE && value1 != NULL_TREE && + pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value1))) + pedwarn ("label must have integral type in ANSI C"); + + if (low_value == NULL_TREE) + success = pushcase (NULL_TREE, 0, label, &duplicate); + else if (high_value == NULL_TREE) + success = pushcase (value1, convert_and_check, label, + &duplicate); + else + success = pushcase_range (value1, value2, convert_and_check, + label, &duplicate); + + if (success == 1) + { + if (low_value == NULL_TREE) + error ("default label not within a switch statement"); + else + error ("case label not within a switch statement"); + } + else if (success == 2) { + if (low_value == NULL_TREE) + { + error ("multiple default labels in one switch"); + error_with_decl (duplicate, "this is the first default label"); + } + else + error ("dupicate case value"); + if (high_value != NULL_TREE) + error_with_decl (duplicate, "this is the first entry for that value"); + } + else if (low_value != NULL_TREE) + { + if (success == 3) + warning ("case value out of range"); + else if (success == 5) + error ("case label within scope of cleanup or variable array"); + } + } } /* Language specific handler of tree nodes used when generating RTL @@ -6863,3 +6918,4 @@ set_current_function_name_declared (i) { abort (); } + |