Commit 4d2fb769 by Nathan Froyd Committed by Nathan Froyd

name-lookup.h (cp_label_binding): Declare.

	* name-lookup.h (cp_label_binding): Declare.  Declare a VEC type
	containing it.
	(cp_binding_level): Convert shadowed_labels and dead_vars_from_for
	fields to VECs.
	* decl.c (poplevel): Adjust for type changes.
	(declare_local_label): Likewise.

From-SVN: r162991
parent daf30b2f
2010-08-07 Nathan Froyd <froydnj@codesourcery.com>
* name-lookup.h (cp_label_binding): Declare. Declare a VEC type
containing it.
(cp_binding_level): Convert shadowed_labels and dead_vars_from_for
fields to VECs.
* decl.c (poplevel): Adjust for type changes.
(declare_local_label): Likewise.
2010-08-06 Jason Merrill <jason@redhat.com> 2010-08-06 Jason Merrill <jason@redhat.com>
* typeck.c (complete_type_or_maybe_complain): Split out from... * typeck.c (complete_type_or_maybe_complain): Split out from...
......
...@@ -543,6 +543,8 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -543,6 +543,8 @@ poplevel (int keep, int reverse, int functionbody)
tree decl; tree decl;
int leaving_for_scope; int leaving_for_scope;
scope_kind kind; scope_kind kind;
unsigned ix;
cp_label_binding *label_bind;
timevar_push (TV_NAME_LOOKUP); timevar_push (TV_NAME_LOOKUP);
restart: restart:
...@@ -687,10 +689,9 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -687,10 +689,9 @@ poplevel (int keep, int reverse, int functionbody)
/* Add it to the list of dead variables in the next /* Add it to the list of dead variables in the next
outermost binding to that we can remove these when we outermost binding to that we can remove these when we
leave that binding. */ leave that binding. */
current_binding_level->level_chain->dead_vars_from_for VEC_safe_push (tree, gc,
= tree_cons (NULL_TREE, link, current_binding_level->level_chain->dead_vars_from_for,
current_binding_level->level_chain-> link);
dead_vars_from_for);
/* Although we don't pop the cxx_binding, we do clear /* Although we don't pop the cxx_binding, we do clear
its SCOPE since the scope is going away now. */ its SCOPE since the scope is going away now. */
...@@ -719,9 +720,10 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -719,9 +720,10 @@ poplevel (int keep, int reverse, int functionbody)
/* Remove declarations for any `for' variables from inner scopes /* Remove declarations for any `for' variables from inner scopes
that we kept around. */ that we kept around. */
for (link = current_binding_level->dead_vars_from_for; for (ix = VEC_length (tree, current_binding_level->dead_vars_from_for) - 1;
link; link = TREE_CHAIN (link)) VEC_iterate (tree, current_binding_level->dead_vars_from_for, ix, decl);
pop_binding (DECL_NAME (TREE_VALUE (link)), TREE_VALUE (link)); ix--)
pop_binding (DECL_NAME (decl), decl);
/* Restore the IDENTIFIER_TYPE_VALUEs. */ /* Restore the IDENTIFIER_TYPE_VALUEs. */
for (link = current_binding_level->type_shadowed; for (link = current_binding_level->type_shadowed;
...@@ -729,10 +731,12 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -729,10 +731,12 @@ poplevel (int keep, int reverse, int functionbody)
SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link), TREE_VALUE (link)); SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link), TREE_VALUE (link));
/* Restore the IDENTIFIER_LABEL_VALUEs for local labels. */ /* Restore the IDENTIFIER_LABEL_VALUEs for local labels. */
for (link = current_binding_level->shadowed_labels; for (ix = VEC_length (cp_label_binding,
link; current_binding_level->shadowed_labels) - 1;
link = TREE_CHAIN (link)) VEC_iterate (cp_label_binding, current_binding_level->shadowed_labels,
pop_local_label (TREE_VALUE (link), TREE_PURPOSE (link)); ix, label_bind);
ix--)
pop_local_label (label_bind->label, label_bind->prev_value);
/* There may be OVERLOADs (wrapped in TREE_LISTs) on the BLOCK_VARs /* There may be OVERLOADs (wrapped in TREE_LISTs) on the BLOCK_VARs
list if a `using' declaration put them there. The debugging list if a `using' declaration put them there. The debugging
...@@ -2508,16 +2512,17 @@ lookup_label (tree id) ...@@ -2508,16 +2512,17 @@ lookup_label (tree id)
tree tree
declare_local_label (tree id) declare_local_label (tree id)
{ {
tree decl, shadow; tree decl;
cp_label_binding *bind;
/* Add a new entry to the SHADOWED_LABELS list so that when we leave /* Add a new entry to the SHADOWED_LABELS list so that when we leave
this scope we can restore the old value of IDENTIFIER_TYPE_VALUE. */ this scope we can restore the old value of IDENTIFIER_TYPE_VALUE. */
shadow = tree_cons (IDENTIFIER_LABEL_VALUE (id), NULL_TREE, bind = VEC_safe_push (cp_label_binding, gc,
current_binding_level->shadowed_labels); current_binding_level->shadowed_labels, NULL);
current_binding_level->shadowed_labels = shadow; bind->prev_value = IDENTIFIER_LABEL_VALUE (id);
decl = make_label_decl (id, /*local_p=*/1); decl = make_label_decl (id, /*local_p=*/1);
TREE_VALUE (shadow) = decl; bind->label = decl;
return decl; return decl;
} }
......
...@@ -148,6 +148,16 @@ typedef struct GTY(()) cp_class_binding { ...@@ -148,6 +148,16 @@ typedef struct GTY(()) cp_class_binding {
DEF_VEC_O(cp_class_binding); DEF_VEC_O(cp_class_binding);
DEF_VEC_ALLOC_O(cp_class_binding,gc); DEF_VEC_ALLOC_O(cp_class_binding,gc);
typedef struct GTY(()) cp_label_binding {
/* The bound LABEL_DECL. */
tree label;
/* The previous IDENTIFIER_LABEL_VALUE. */
tree prev_value;
} cp_label_binding;
DEF_VEC_O(cp_label_binding);
DEF_VEC_ALLOC_O(cp_label_binding,gc);
/* For each binding contour we allocate a binding_level structure /* For each binding contour we allocate a binding_level structure
which records the names defined in that contour. which records the names defined in that contour.
Contours include: Contours include:
...@@ -206,10 +216,9 @@ struct GTY(()) cp_binding_level { ...@@ -206,10 +216,9 @@ struct GTY(()) cp_binding_level {
the class. */ the class. */
tree type_shadowed; tree type_shadowed;
/* A TREE_LIST. Each TREE_VALUE is the LABEL_DECL for a local /* Similar to class_shadowed, but for IDENTIFIER_LABEL_VALUE, and
label in this scope. The TREE_PURPOSE is the previous value of used for all binding levels. */
the IDENTIFIER_LABEL VALUE. */ VEC(cp_label_binding,gc) *shadowed_labels;
tree shadowed_labels;
/* For each level (except not the global one), /* For each level (except not the global one),
a chain of BLOCK nodes for all the levels a chain of BLOCK nodes for all the levels
...@@ -225,9 +234,8 @@ struct GTY(()) cp_binding_level { ...@@ -225,9 +234,8 @@ struct GTY(()) cp_binding_level {
/* List of VAR_DECLS saved from a previous for statement. /* List of VAR_DECLS saved from a previous for statement.
These would be dead in ISO-conforming code, but might These would be dead in ISO-conforming code, but might
be referenced in ARM-era code. These are stored in a be referenced in ARM-era code. */
TREE_LIST; the TREE_VALUE is the actual declaration. */ VEC(tree,gc) *dead_vars_from_for;
tree dead_vars_from_for;
/* STATEMENT_LIST for statements in this binding contour. /* STATEMENT_LIST for statements in this binding contour.
Only used at present for SK_CLEANUP temporary bindings. */ Only used at present for SK_CLEANUP temporary bindings. */
......
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