From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Iverson To: egcs@cygnus.com Cc: Jason Merrill Subject: Followup to templated label bug report. Date: Mon, 15 Dec 1997 13:47:00 -0000 Message-id: <199712152147.NAA06614@Canada.AI.SRI.COM> X-SW-Source: 1997-12/msg00861.html WRT. the code in Set.instance.i, it seems that CoolSet::resize is being instantiated inside CoolSetCoolSet::put, and thus push_to_top_level is called. Now, the id for retry is shared between the minimal_parse'ed versions of the two templated functions, but maybe_push_to_top_level clears named_labels but does not clear the individual bindings stored in IDENTIFIER_LABEL_VALUE for each label. It seems to me that what must be done is to actually save these bindings in maybe_push_to_top_level and then restore them in pop_from_top_level. The patch below implements this and fixes the bug I previously reported. ------------------------------------------------------------------------------- Lee Iverson SRI International leei@ai.sri.com 333 Ravenswood Ave., Menlo Park CA 94025 http://www.ai.sri.com/~leei/ (650) 859-3307 1997-12-15 Lee Iverson * decl.c (struct saved_scope): Add label_bindings component for save/restore of label bindings. (maybe_push_to_top_level): Save label bindings in named_labels to label_bindings. (pop_from_top_level): Restore named_labels from label_bindings. *** decl.c.~1~ Sat Dec 6 16:30:39 1997 --- decl.c Mon Dec 15 13:38:05 1997 *************** struct saved_scope { *** 1832,1835 **** --- 1832,1836 ---- HOST_WIDE_INT processing_template_decl; tree previous_class_type, previous_class_values; + tree label_bindings; }; static struct saved_scope *current_saved_scope; *************** maybe_push_to_top_level (pseudo) *** 1886,1889 **** --- 1887,1891 ---- struct binding_level *b = inner_binding_level; tree old_bindings = NULL_TREE; + tree link; if (current_function_decl) *************** maybe_push_to_top_level (pseudo) *** 1916,1919 **** --- 1918,1933 ---- current_binding_level = b; + /* Save current label bindings. */ + s->label_bindings = NULL_TREE; + for (link = named_labels; link; link = TREE_CHAIN (link)) + { + tree label = TREE_VALUE (link); + tree name = DECL_NAME (label); + s->label_bindings = tree_cons (label, + IDENTIFIER_LABEL_VALUE (name), + s->label_bindings); + SET_IDENTIFIER_LABEL_VALUE (name, NULL_TREE); + } + s->class_name = current_class_name; s->class_type = current_class_type; *************** pop_from_top_level () *** 1989,1992 **** --- 2003,2016 ---- } } + + named_labels = NULL_TREE; + for (t = s->label_bindings; t; t = TREE_CHAIN (t)) + { + tree decl = TREE_PURPOSE (t); + tree val = TREE_VALUE (t); + SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (decl), val); + named_labels = tree_cons (NULL_TREE, decl, named_labels); + } + current_class_name = s->class_name; current_class_type = s->class_type;