Commit 6625cdb5 by Jason Merrill Committed by Jason Merrill

Fix goto checking.

        * cp-tree.h (struct language_function): x_named_labels is now
        a struct named_label_list*.
        * decl.c (struct named_label_use_list): Renamed from...
        (struct named_label_list): ...this.  New struct.
        (push_binding_level): Don't set eh_region.
        (note_level_for_eh): New fn.
        (pop_label): Take label and old value directly.
        (pop_labels): Adjust for new named_labels format.
        (lookup_label): Likewise.
        (poplevel): Note characteristics of a binding level containing a
        named label.  Mess with named label lists earlier.
        (mark_named_label_lists): New fn.
        (mark_lang_function): Call it.
        (use_label): New fn, split out from...
        (make_label_decl): ...here.  Don't call it.
        (decl_jump_unsafe, check_previous_goto, check_previous_goto_1,
        check_previous_gotos): New fns, split out from...
        (define_label): ...here.
        (check_switch_goto): New fn.
        (define_case_label): Call it.
        (check_goto): New fn.
        * semantics.c (finish_goto_stmt): Call it and use_label.
        (begin_compound_stmt): If we're a try block, call note_level_for_eh.
        (expand_stmt): Never pass 1 as DONT_JUMP_IN to expand_end_bindings.

From-SVN: r34198
parent 0137be2d
2000-05-26 Jason Merrill <jason@casey.soma.redhat.com>
Fix goto checking.
* cp-tree.h (struct language_function): x_named_labels is now
a struct named_label_list*.
* decl.c (struct named_label_use_list): Renamed from...
(struct named_label_list): ...this. New struct.
(push_binding_level): Don't set eh_region.
(note_level_for_eh): New fn.
(pop_label): Take label and old value directly.
(pop_labels): Adjust for new named_labels format.
(lookup_label): Likewise.
(poplevel): Note characteristics of a binding level containing a
named label. Mess with named label lists earlier.
(mark_named_label_lists): New fn.
(mark_lang_function): Call it.
(use_label): New fn, split out from...
(make_label_decl): ...here. Don't call it.
(decl_jump_unsafe, check_previous_goto, check_previous_goto_1,
check_previous_gotos): New fns, split out from...
(define_label): ...here.
(check_switch_goto): New fn.
(define_case_label): Call it.
(check_goto): New fn.
* semantics.c (finish_goto_stmt): Call it and use_label.
(begin_compound_stmt): If we're a try block, call note_level_for_eh.
(expand_stmt): Never pass 1 as DONT_JUMP_IN to expand_end_bindings.
2000-05-26 Mark Mitchell <mark@codesourcery.com> 2000-05-26 Mark Mitchell <mark@codesourcery.com>
* class.c (build_vtable_entry_ref): Correct usage of * class.c (build_vtable_entry_ref): Correct usage of
......
...@@ -841,7 +841,6 @@ extern struct saved_scope *scope_chain; ...@@ -841,7 +841,6 @@ extern struct saved_scope *scope_chain;
struct language_function struct language_function
{ {
tree x_named_labels;
tree x_ctor_label; tree x_ctor_label;
tree x_dtor_label; tree x_dtor_label;
tree x_base_init_list; tree x_base_init_list;
...@@ -867,7 +866,8 @@ struct language_function ...@@ -867,7 +866,8 @@ struct language_function
struct stmt_tree x_stmt_tree; struct stmt_tree x_stmt_tree;
struct named_label_list *x_named_label_uses; struct named_label_use_list *x_named_label_uses;
struct named_label_list *x_named_labels;
struct binding_level *bindings; struct binding_level *bindings;
const char *cannot_inline; const char *cannot_inline;
...@@ -3892,6 +3892,7 @@ extern void set_class_shadows PARAMS ((tree)); ...@@ -3892,6 +3892,7 @@ extern void set_class_shadows PARAMS ((tree));
extern void begin_scope PARAMS ((scope_kind)); extern void begin_scope PARAMS ((scope_kind));
extern void finish_scope PARAMS ((void)); extern void finish_scope PARAMS ((void));
extern void note_level_for_for PARAMS ((void)); extern void note_level_for_for PARAMS ((void));
extern void note_level_for_eh PARAMS ((void));
extern void resume_level PARAMS ((struct binding_level *)); extern void resume_level PARAMS ((struct binding_level *));
extern void delete_block PARAMS ((tree)); extern void delete_block PARAMS ((tree));
extern void insert_block PARAMS ((tree)); extern void insert_block PARAMS ((tree));
...@@ -3930,6 +3931,7 @@ extern tree implicitly_declare PARAMS ((tree)); ...@@ -3930,6 +3931,7 @@ extern tree implicitly_declare PARAMS ((tree));
extern tree lookup_label PARAMS ((tree)); extern tree lookup_label PARAMS ((tree));
extern tree declare_local_label PARAMS ((tree)); extern tree declare_local_label PARAMS ((tree));
extern tree define_label PARAMS ((const char *, int, tree)); extern tree define_label PARAMS ((const char *, int, tree));
extern void check_goto PARAMS ((tree));
extern void push_switch PARAMS ((void)); extern void push_switch PARAMS ((void));
extern void pop_switch PARAMS ((void)); extern void pop_switch PARAMS ((void));
extern void define_case_label PARAMS ((void)); extern void define_case_label PARAMS ((void));
......
...@@ -703,6 +703,8 @@ finish_goto_stmt (destination) ...@@ -703,6 +703,8 @@ finish_goto_stmt (destination)
addresses, or some such. */ addresses, or some such. */
DECL_UNINLINABLE (current_function_decl) = 1; DECL_UNINLINABLE (current_function_decl) = 1;
check_goto (destination);
add_tree (build_min_nt (GOTO_STMT, destination)); add_tree (build_min_nt (GOTO_STMT, destination));
} }
else else
...@@ -965,10 +967,15 @@ begin_compound_stmt (has_no_scope) ...@@ -965,10 +967,15 @@ begin_compound_stmt (has_no_scope)
int has_no_scope; int has_no_scope;
{ {
tree r; tree r;
int is_try = 0;
if (building_stmt_tree ()) if (building_stmt_tree ())
{ {
r = build_min_nt (COMPOUND_STMT, NULL_TREE); r = build_min_nt (COMPOUND_STMT, NULL_TREE);
/* Mark that this block is for a try so that we can yell at
people trying to jump in. */
if (last_tree && TREE_CODE (last_tree) == TRY_BLOCK)
is_try = 1;
add_tree (r); add_tree (r);
if (has_no_scope) if (has_no_scope)
COMPOUND_STMT_NO_SCOPE (r) = 1; COMPOUND_STMT_NO_SCOPE (r) = 1;
...@@ -979,7 +986,11 @@ begin_compound_stmt (has_no_scope) ...@@ -979,7 +986,11 @@ begin_compound_stmt (has_no_scope)
last_expr_type = NULL_TREE; last_expr_type = NULL_TREE;
if (!has_no_scope) if (!has_no_scope)
do_pushlevel (); {
do_pushlevel ();
if (is_try)
note_level_for_eh ();
}
else else
/* Normally, we try hard to keep the BLOCK for a /* Normally, we try hard to keep the BLOCK for a
statement-expression. But, if it's a statement-expression with statement-expression. But, if it's a statement-expression with
...@@ -2581,8 +2592,7 @@ expand_stmt (t) ...@@ -2581,8 +2592,7 @@ expand_stmt (t)
expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t), expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t),
SCOPE_STMT_BLOCK (t)); SCOPE_STMT_BLOCK (t));
else if (SCOPE_END_P (t)) else if (SCOPE_END_P (t))
expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
SCOPE_PARTIAL_P (t));
} }
else if (!SCOPE_NULLIFIED_P (t)) else if (!SCOPE_NULLIFIED_P (t))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment