Commit cfe507be by Mark Mitchell Committed by Mark Mitchell

decl.c (add_decl_to_level): New function.

	* decl.c (add_decl_to_level): New function.
	(push_local_binding): Use it.
	(find_binding): Fix typo in comment.
	(pushdecl): Use add_decl_to_level.  Put templates on the
	corresponding namespace-scope binding levels.
	* dump.c (dequeue_and_dump): Print the specializations of a
	template.
	* pt.c (push_template_decl_real): Don't push a template multiple
	times.

From-SVN: r28738
parent db4b04f1
1999-08-17 Mark Mitchell <mark@codesourcery.com> 1999-08-17 Mark Mitchell <mark@codesourcery.com>
* decl.c (add_decl_to_level): New function.
(push_local_binding): Use it.
(find_binding): Fix typo in comment.
(pushdecl): Use add_decl_to_level. Put templates on the
corresponding namespace-scope binding levels.
* dump.c (dequeue_and_dump): Print the specializations of a
template.
* pt.c (push_template_decl_real): Don't push a template multiple
times.
1999-08-17 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CALL_DECLARATOR_PARMS): New macro. * cp-tree.h (CALL_DECLARATOR_PARMS): New macro.
(CALL_DECLARATOR_QUALS): Likewise. (CALL_DECLARATOR_QUALS): Likewise.
(CALL_DECARATOR_EXCEPTION_SPEC): Likewise. (CALL_DECARATOR_EXCEPTION_SPEC): Likewise.
......
...@@ -189,6 +189,7 @@ static tree poplevel_class PROTO((void)); ...@@ -189,6 +189,7 @@ static tree poplevel_class PROTO((void));
static void warn_about_implicit_typename_lookup PROTO((tree, tree)); static void warn_about_implicit_typename_lookup PROTO((tree, tree));
static int walk_namespaces_r PROTO((tree, walk_namespaces_fn, void *)); static int walk_namespaces_r PROTO((tree, walk_namespaces_fn, void *));
static int walk_globals_r PROTO((tree, void *)); static int walk_globals_r PROTO((tree, void *));
static void add_decl_to_level PROTO((tree, struct binding_level *));
#if defined (DEBUG_CP_BINDING_LEVELS) #if defined (DEBUG_CP_BINDING_LEVELS)
static void indent PROTO((void)); static void indent PROTO((void));
...@@ -1099,9 +1100,29 @@ add_binding (id, decl) ...@@ -1099,9 +1100,29 @@ add_binding (id, decl)
return ok; return ok;
} }
/* Bind DECL to ID in the current_binding_level. /* Add DECL to the list of things declared in B. */
If PUSH_USING is set in FLAGS, we know that DECL doesn't really belong
to this binding level, that it got here through a using-declaration. */ static void
add_decl_to_level (decl, b)
tree decl;
struct binding_level *b;
{
/* Only things that will live forever should go in the global
binding level. */
my_friendly_assert (!(b == global_binding_level
&& !TREE_PERMANENT (decl)),
19990817);
/* We build up the list in reverse order, and reverse it later if
necessary. */
TREE_CHAIN (decl) = b->names;
b->names = decl;
}
/* Bind DECL to ID in the current_binding_level, assumed to be a local
binding level. If PUSH_USING is set in FLAGS, we know that DECL
doesn't really belong to this binding level, that it got here
through a using-declaration. */
void void
push_local_binding (id, decl, flags) push_local_binding (id, decl, flags)
...@@ -1138,8 +1159,7 @@ push_local_binding (id, decl, flags) ...@@ -1138,8 +1159,7 @@ push_local_binding (id, decl, flags)
/* And put DECL on the list of things declared by the current /* And put DECL on the list of things declared by the current
binding level. */ binding level. */
TREE_CHAIN (decl) = b->names; add_decl_to_level (decl, b);
b->names = decl;
} }
/* Bind DECL to ID in the class_binding_level. Returns nonzero if the /* Bind DECL to ID in the class_binding_level. Returns nonzero if the
...@@ -2148,7 +2168,7 @@ find_binding (name, scope) ...@@ -2148,7 +2168,7 @@ find_binding (name, scope)
my_friendly_assert (TREE_CODE (iter) == CPLUS_BINDING, 374); my_friendly_assert (TREE_CODE (iter) == CPLUS_BINDING, 374);
if (BINDING_SCOPE (iter) == scope) if (BINDING_SCOPE (iter) == scope)
{ {
/* Move binding found to the fron of the list, so /* Move binding found to the front of the list, so
subsequent lookups will find it faster. */ subsequent lookups will find it faster. */
if (prev) if (prev)
{ {
...@@ -3955,7 +3975,12 @@ pushdecl (x) ...@@ -3955,7 +3975,12 @@ pushdecl (x)
need_new_binding = 0; need_new_binding = 0;
} }
else if (DECL_FUNCTION_TEMPLATE_P (x) && DECL_NAMESPACE_SCOPE_P (x)) else if (DECL_FUNCTION_TEMPLATE_P (x) && DECL_NAMESPACE_SCOPE_P (x))
return push_overloaded_decl (x, PUSH_GLOBAL); {
t = push_overloaded_decl (x, PUSH_GLOBAL);
if (t == x)
add_decl_to_level (x, NAMESPACE_LEVEL (CP_DECL_CONTEXT (t)));
return t;
}
/* If declaring a type as a typedef, copy the type (unless we're /* If declaring a type as a typedef, copy the type (unless we're
at line 0), and install this TYPE_DECL as the new type's typedef at line 0), and install this TYPE_DECL as the new type's typedef
...@@ -4189,15 +4214,7 @@ pushdecl (x) ...@@ -4189,15 +4214,7 @@ pushdecl (x)
} }
if (need_new_binding) if (need_new_binding)
{ add_decl_to_level (x, current_binding_level);
/* Put decls on list in reverse order.
We will reverse them later if necessary. */
TREE_CHAIN (x) = current_binding_level->names;
current_binding_level->names = x;
if (current_binding_level == global_binding_level
&& !TREE_PERMANENT (x))
my_friendly_abort (124);
}
return x; return x;
} }
......
...@@ -606,7 +606,7 @@ dequeue_and_dump (di) ...@@ -606,7 +606,7 @@ dequeue_and_dump (di)
if (DECL_CONV_FN_P (t)) if (DECL_CONV_FN_P (t))
dump_string (di, "conversion"); dump_string (di, "conversion");
if (dump_children_p) if (dump_children_p)
dump_child ("body", DECL_INITIAL (t)); dump_child ("body", DECL_SAVED_TREE (t));
break; break;
case NAMESPACE_DECL: case NAMESPACE_DECL:
...@@ -618,6 +618,11 @@ dequeue_and_dump (di) ...@@ -618,6 +618,11 @@ dequeue_and_dump (di)
dump_child ("dcls", cp_namespace_decls (t)); dump_child ("dcls", cp_namespace_decls (t));
break; break;
case TEMPLATE_DECL:
if (dump_children_p)
dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
break;
case OVERLOAD: case OVERLOAD:
if (dump_children_p) if (dump_children_p)
{ {
......
...@@ -2385,6 +2385,7 @@ push_template_decl_real (decl, is_friend) ...@@ -2385,6 +2385,7 @@ push_template_decl_real (decl, is_friend)
tree ctx; tree ctx;
int primary; int primary;
int is_partial; int is_partial;
int new_template_p = 0;
/* See if this is a partial specialization. */ /* See if this is a partial specialization. */
is_partial = (DECL_IMPLICIT_TYPEDEF_P (decl) is_partial = (DECL_IMPLICIT_TYPEDEF_P (decl)
...@@ -2449,7 +2450,8 @@ push_template_decl_real (decl, is_friend) ...@@ -2449,7 +2450,8 @@ push_template_decl_real (decl, is_friend)
else else
{ {
tmpl = build_template_decl (decl, current_template_parms); tmpl = build_template_decl (decl, current_template_parms);
new_template_p = 1;
if (DECL_LANG_SPECIFIC (decl) if (DECL_LANG_SPECIFIC (decl)
&& DECL_TEMPLATE_SPECIALIZATION (decl)) && DECL_TEMPLATE_SPECIALIZATION (decl))
{ {
...@@ -2560,7 +2562,7 @@ push_template_decl_real (decl, is_friend) ...@@ -2560,7 +2562,7 @@ push_template_decl_real (decl, is_friend)
that we do not try to push a global template friend declared in a that we do not try to push a global template friend declared in a
template class; such a thing may well depend on the template template class; such a thing may well depend on the template
parameters of the class. */ parameters of the class. */
if (! ctx if (new_template_p && !ctx
&& !(is_friend && template_class_depth (current_class_type) > 0)) && !(is_friend && template_class_depth (current_class_type) > 0))
tmpl = pushdecl_namespace_level (tmpl); tmpl = pushdecl_namespace_level (tmpl);
......
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