Commit e0942dcd by Mark Mitchell Committed by Mark Mitchell

pt.c (check_default_tmpl_args): Don't check in local scopes.

	* pt.c (check_default_tmpl_args): Don't check in local scopes.
	(tsubst_decl): Make sure the declaration is on a saveable
	obstack.  Clear DECL_DEAD_FOR_LOCAL when making a copy of a local
	variable.
	(tsubst_expr): Adjust now that DECL_STMTs really contain DECLs.

From-SVN: r28715
parent 66e06429
1999-08-15 Mark Mitchell <mark@codesourcery.com>
* pt.c (check_default_tmpl_args): Don't check in local scopes.
(tsubst_decl): Make sure the declaration is on a saveable
obstack. Clear DECL_DEAD_FOR_LOCAL when making a copy of a local
variable.
(tsubst_expr): Adjust now that DECL_STMTs really contain DECLs.
1999-08-14 Jason Merrill <jason@yorick.cygnus.com> 1999-08-14 Jason Merrill <jason@yorick.cygnus.com>
Speed up Koenig lookup. Speed up Koenig lookup.
......
...@@ -2247,6 +2247,12 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial) ...@@ -2247,6 +2247,12 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial)
in the template-parameter-list of the definition of a member of a in the template-parameter-list of the definition of a member of a
class template. */ class template. */
if (TREE_CODE (DECL_REAL_CONTEXT (decl)) == FUNCTION_DECL)
/* You can't have a function template declaration in a local
scope, nor you can you define a member of a class template in a
local scope. */
return;
if (current_class_type if (current_class_type
&& !TYPE_BEING_DEFINED (current_class_type) && !TYPE_BEING_DEFINED (current_class_type)
&& DECL_LANG_SPECIFIC (decl) && DECL_LANG_SPECIFIC (decl)
...@@ -6035,7 +6041,13 @@ tsubst_decl (t, args, type, in_decl) ...@@ -6035,7 +6041,13 @@ tsubst_decl (t, args, type, in_decl)
break; break;
} }
/* This declaration is going to have to be around for a while,
so me make sure it is on a saveable obstack. */
push_obstacks_nochange ();
saveable_allocation ();
r = copy_node (t); r = copy_node (t);
pop_obstacks ();
TREE_TYPE (r) = type; TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r); c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
DECL_CONTEXT (r) = ctx; DECL_CONTEXT (r) = ctx;
...@@ -6048,10 +6060,16 @@ tsubst_decl (t, args, type, in_decl) ...@@ -6048,10 +6060,16 @@ tsubst_decl (t, args, type, in_decl)
copy_lang_decl (r); copy_lang_decl (r);
DECL_CLASS_CONTEXT (r) = DECL_CONTEXT (r); DECL_CLASS_CONTEXT (r) = DECL_CONTEXT (r);
/* Even if the original location is out of scope, the newly
substituted one is not. */
if (TREE_CODE (r) == VAR_DECL)
DECL_DEAD_FOR_LOCAL (r) = 0;
/* A static data member declaration is always marked external /* A static data member declaration is always marked external
when it is declared in-class, even if an initializer is when it is declared in-class, even if an initializer is
present. We mimic the non-template processing here. */ present. We mimic the non-template processing here. */
DECL_EXTERNAL (r) = 1; if (ctx)
DECL_EXTERNAL (r) = 1;
DECL_TEMPLATE_INFO (r) = perm_tree_cons (tmpl, argvec, NULL_TREE); DECL_TEMPLATE_INFO (r) = perm_tree_cons (tmpl, argvec, NULL_TREE);
SET_DECL_IMPLICIT_INSTANTIATION (r); SET_DECL_IMPLICIT_INSTANTIATION (r);
...@@ -7231,19 +7249,25 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7231,19 +7249,25 @@ tsubst_expr (t, args, complain, in_decl)
case DECL_STMT: case DECL_STMT:
{ {
int i = suspend_momentary (); int i = suspend_momentary ();
tree dcl, init; tree decl;
tree init;
lineno = STMT_LINENO (t); lineno = STMT_LINENO (t);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
dcl = start_decl decl = DECL_STMT_DECL (t);
(tsubst (TREE_OPERAND (t, 0), args, complain, in_decl), init = DECL_INITIAL (decl);
tsubst (TREE_OPERAND (t, 1), args, complain, in_decl), decl = tsubst (decl, args, complain, in_decl);
TREE_OPERAND (t, 2) != 0, NULL_TREE, NULL_TREE); init = tsubst_expr (init, args, complain, in_decl);
init = tsubst_expr (TREE_OPERAND (t, 2), args, complain, in_decl); DECL_INITIAL (decl) = init;
maybe_push_decl (decl);
if (TREE_CODE (decl) == VAR_DECL)
DECL_TEMPLATE_INSTANTIATED (decl) = 1;
maybe_push_decl (decl);
start_decl_1 (decl);
cp_finish_decl cp_finish_decl
(dcl, init, NULL_TREE, 1, /*init ? LOOKUP_ONLYCONVERTING :*/ 0); (decl, init, NULL_TREE, 0, /*init ? LOOKUP_ONLYCONVERTING :*/ 0);
resume_momentary (i); resume_momentary (i);
return dcl; return decl;
} }
case FOR_STMT: case FOR_STMT:
......
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