From 826840d96aa1722381e57d96df700528c4581c33 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 28 Mar 2001 00:25:45 -0800 Subject: [PATCH] decl.c (struct named_label_list): Rename eh_region to in_try_scope, add in_catch_scope. * decl.c (struct named_label_list): Rename eh_region to in_try_scope, add in_catch_scope. (struct binding_level): Rename eh_region to is_try_scope, add is_catch_scope. (note_level_for_try): Rename from note_level_for_eh. (note_level_for_catch): New. (poplevel): Copy both is_try_scope and is_catch_scope to the named_label_list struct. (check_previous_goto_1): Don't check for catch block via DECL_ARTIFICIAL; use in_try_scope instead. (check_goto): Likewise. * cp-tree.h (note_level_for_try, note_level_for_catch): Declare. * except.c (expand_start_catch_block): Call note_level_for_catch. * semantics.c (begin_compound_stmt): Update for note_level_for_try. From-SVN: r40920 --- gcc/cp/ChangeLog | 25 +++++++++++++++++++++---- gcc/cp/cp-tree.h | 3 ++- gcc/cp/decl.c | 53 +++++++++++++++++++++++++++++++++++------------------ gcc/cp/except.c | 1 + gcc/cp/semantics.c | 2 +- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c30478f..9540023 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,20 @@ +2001-03-28 Richard Henderson + + * decl.c (struct named_label_list): Rename eh_region to + in_try_scope, add in_catch_scope. + (struct binding_level): Rename eh_region to is_try_scope, + add is_catch_scope. + (note_level_for_try): Rename from note_level_for_eh. + (note_level_for_catch): New. + (poplevel): Copy both is_try_scope and is_catch_scope to + the named_label_list struct. + (check_previous_goto_1): Don't check for catch block via + DECL_ARTIFICIAL; use in_try_scope instead. + (check_goto): Likewise. + * cp-tree.h (note_level_for_try, note_level_for_catch): Declare. + * except.c (expand_start_catch_block): Call note_level_for_catch. + * semantics.c (begin_compound_stmt): Update for note_level_for_try. + 2001-03-27 Richard Henderson * except.c: Use USING_SJLJ_EXCEPTIONS instead of @@ -124,7 +141,7 @@ * except.c: Don't include it. 2001-03-22 Gerald Pfeifer - based on an idea from Joe Buck + based on an idea from Joe Buck * parse.y (bad_decl, template_arg_list_ignore, arg_list_ignore): New nonterminals. @@ -1041,8 +1058,8 @@ Sun Feb 4 15:52:44 2001 Richard Kenner 2001-01-16 Daniel Berlin - * cvt.c (ocp_convert): Handle vector type conversion - * typeck2.c (digest_init): Handle vector type initializations + * cvt.c (ocp_convert): Handle vector type conversion + * typeck2.c (digest_init): Handle vector type initializations 2001-01-16 Phil Edwards @@ -1249,7 +1266,7 @@ Sun Feb 4 15:52:44 2001 Richard Kenner 2001-01-07 Neil Booth - * cp/decl2.c (cxx_post_options): Call cpp_post_options. + * cp/decl2.c (cxx_post_options): Call cpp_post_options. 2001-01-05 Nathan Sidwell diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5015349..91c280c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3766,7 +3766,8 @@ extern void maybe_push_cleanup_level PARAMS ((tree)); extern void begin_scope PARAMS ((scope_kind)); extern void finish_scope PARAMS ((void)); extern void note_level_for_for PARAMS ((void)); -extern void note_level_for_eh PARAMS ((void)); +extern void note_level_for_try PARAMS ((void)); +extern void note_level_for_catch PARAMS ((void)); extern void resume_level PARAMS ((struct binding_level *)); extern void delete_block PARAMS ((tree)); extern void insert_block PARAMS ((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 92ee8ed..366d37c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -282,8 +282,9 @@ struct named_label_list tree old_value; tree label_decl; tree bad_decls; - int eh_region; struct named_label_list *next; + unsigned int in_try_scope : 1; + unsigned int in_catch_scope : 1; }; #define named_labels cp_function_chain->x_named_labels @@ -456,12 +457,15 @@ struct binding_level worry about ambiguous (ARM or ISO) scope rules. */ unsigned is_for_scope : 1; - /* True if this level corresponds to an EH region, as for a try block. - Currently this information is only available while building the - tree structure. */ - unsigned eh_region : 1; + /* True if this level corresponds to a TRY block. Currently this + information is only available while building the tree structure. */ + unsigned is_try_scope : 1; - /* Four bits left for this word. */ + /* True if this level corresponds to a CATCH block. Currently this + information is only available while building the tree structure. */ + unsigned is_catch_scope : 1; + + /* Three bits left for this word. */ #if defined(DEBUG_CP_BINDING_LEVELS) /* Binding depth at which this level began. */ @@ -920,9 +924,17 @@ note_level_for_for () /* Record that the current binding level represents a try block. */ void -note_level_for_eh () +note_level_for_try () { - current_binding_level->eh_region = 1; + current_binding_level->is_try_scope = 1; +} + +/* Record that the current binding level represents a catch block. */ + +void +note_level_for_catch () +{ + current_binding_level->is_catch_scope = 1; } /* For a binding between a name and an entity at a block scope, @@ -1326,8 +1338,10 @@ poplevel (keep, reverse, functionbody) if (labels->binding_level == current_binding_level) { tree decl; - if (current_binding_level->eh_region) - labels->eh_region = 1; + if (current_binding_level->is_try_scope) + labels->in_try_scope = 1; + if (current_binding_level->is_catch_scope) + labels->in_catch_scope = 1; for (decl = labels->names_in_scope; decl; decl = TREE_CHAIN (decl)) if (decl_jump_unsafe (decl)) @@ -4946,10 +4960,7 @@ check_previous_goto_1 (decl, level, names, file, line) identified = 1; } - if (problem > 1 && DECL_ARTIFICIAL (new_decls)) - /* Can't skip init of __exception_info. */ - cp_error_at (" enters catch block", new_decls); - else if (problem > 1) + if (problem > 1) cp_error_at (" crosses initialization of `%#D'", new_decls); else @@ -4959,7 +4970,7 @@ check_previous_goto_1 (decl, level, names, file, line) if (b == level) break; - if (b->eh_region && ! saw_eh) + if ((b->is_try_scope || b->is_catch_scope) && ! saw_eh) { if (! identified) { @@ -4972,7 +4983,10 @@ check_previous_goto_1 (decl, level, names, file, line) pedwarn_with_file_and_line (file, line, " from here"); identified = 1; } - error (" enters try block"); + if (b->is_try_scope) + error (" enters try block"); + else + error (" enters catch block"); saw_eh = 1; } } @@ -5051,7 +5065,8 @@ check_goto (decl) if (lab == 0) return; - if ((lab->eh_region || lab->bad_decls) && !identified) + if ((lab->in_try_scope || lab->in_catch_scope || lab->bad_decls) + && !identified) { cp_pedwarn_at ("jump to label `%D'", decl); pedwarn (" from here"); @@ -5072,8 +5087,10 @@ check_goto (decl) cp_pedwarn_at (" enters scope of non-POD `%#D'", b); } - if (lab->eh_region) + if (lab->in_try_scope) error (" enters try block"); + else if (lab->in_catch_scope) + error (" enters catch block"); } /* Define a label, specifying the location in the source file. diff --git a/gcc/cp/except.c b/gcc/cp/except.c index ee0bd8c..4f5bde6 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -616,6 +616,7 @@ expand_start_catch_block (decl) /* Create a binding level for the eh_info and the exception object cleanup. */ compound_stmt_1 = begin_compound_stmt (/*has_no_scope=*/0); + note_level_for_catch (); if (! decl || ! decl_is_java_type (TREE_TYPE (decl), 1)) { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5406b3e..a070002 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -832,7 +832,7 @@ begin_compound_stmt (has_no_scope) { do_pushlevel (); if (is_try) - note_level_for_eh (); + note_level_for_try (); } else /* Normally, we try hard to keep the BLOCK for a -- 2.7.4