Commit 8dd3f57a by Mark Mitchell Committed by Mark Mitchell

Fix incorrect commit on previous change.

From-SVN: r28706
parent 0a818f84
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
tree.c (init_cplus_unsave): New. tree.c (init_cplus_unsave): New.
(cplus_unsave_expr_now): New. (cplus_unsave_expr_now): New.
1999-08-13 Mark Mitchell <mark@codesourcery.com>
* pt.c (tsubst): Back out 1999-08-06 patch. Use fold and
decl_constant_value to simplify array bounds.
1999-08-11 Jason Merrill <jason@yorick.cygnus.com> 1999-08-11 Jason Merrill <jason@yorick.cygnus.com>
* lang-options.h: Add -fms-extensions. * lang-options.h: Add -fms-extensions.
......
...@@ -2216,12 +2216,6 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial) ...@@ -2216,12 +2216,6 @@ 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)
...@@ -5063,22 +5057,9 @@ instantiate_class_template (type) ...@@ -5063,22 +5057,9 @@ instantiate_class_template (type)
} }
} }
/* Create the typedef that indicates provides a way of referencing a
class name within the scope of that class. */
build_self_reference ();
/* Don't replace enum constants here. */ /* Don't replace enum constants here. */
for (t = TYPE_FIELDS (pattern); t; t = TREE_CHAIN (t)) for (t = TYPE_FIELDS (pattern); t; t = TREE_CHAIN (t))
/* If this is the implicit self-reference typedef, skip it, as we if (TREE_CODE (t) != CONST_DECL)
have handled it above. Note that the usual tsubst machinery
doesn't work here, since the resulting declaration must have a
different name than the one it was given originally. */
if (TREE_CODE (t) == TYPE_DECL
&& TREE_TYPE (t) == pattern
&& DECL_NAME (t) == constructor_name (t)
&& DECL_ARTIFICIAL (t))
continue;
else if (TREE_CODE (t) != CONST_DECL)
{ {
tree r; tree r;
...@@ -5897,24 +5878,18 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5897,24 +5878,18 @@ tsubst_decl (t, args, type, in_decl)
break; break;
case VAR_DECL: case VAR_DECL:
case TYPE_DECL:
{ {
tree argvec; tree argvec;
tree gen_tmpl; tree gen_tmpl;
tree spec; tree spec;
tree tmpl; tree tmpl;
tree ctx; tree ctx = tsubst_aggr_type (DECL_CONTEXT (t), args,
/*complain=*/1,
if (!DECL_LANG_SPECIFIC (t) || !DECL_TEMPLATE_INFO (t)) in_decl, /*entering_scope=*/1);
return t;
/* Nobody should be tsubst'ing into non-template variables. */
if (TYPE_P (DECL_CONTEXT (t))) my_friendly_assert (DECL_LANG_SPECIFIC (t)
ctx = tsubst_aggr_type (DECL_CONTEXT (t), args, && DECL_TEMPLATE_INFO (t) != NULL_TREE, 0);
/*complain=*/1,
in_decl, /*entering_scope=*/1);
else
/* Subsequent calls to pushdecl will fill this in. */
ctx = NULL_TREE;
/* Check to see if we already have this specialization. */ /* Check to see if we already have this specialization. */
tmpl = DECL_TI_TEMPLATE (t); tmpl = DECL_TI_TEMPLATE (t);
...@@ -5928,13 +5903,7 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5928,13 +5903,7 @@ 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;
...@@ -5947,16 +5916,10 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5947,16 +5916,10 @@ 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. */
if (ctx) DECL_EXTERNAL (r) = 1;
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);
...@@ -5968,6 +5931,18 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5968,6 +5931,18 @@ tsubst_decl (t, args, type, in_decl)
} }
break; break;
case TYPE_DECL:
if (t == TYPE_NAME (TREE_TYPE (t)))
r = TYPE_NAME (type);
else
{
r = copy_node (t);
TREE_TYPE (r) = type;
DECL_CONTEXT (r) = current_class_type;
TREE_CHAIN (r) = NULL_TREE;
}
break;
default: default:
my_friendly_abort (0); my_friendly_abort (0);
} }
...@@ -6043,7 +6018,7 @@ tsubst_function_type (t, args, complain, in_decl) ...@@ -6043,7 +6018,7 @@ tsubst_function_type (t, args, complain, in_decl)
tree arg_types; tree arg_types;
tree fntype; tree fntype;
/* The TYPE_CONEXT is not used for function/method types. */ /* The TYPE_CONTEXT is not used for function/method types. */
my_friendly_assert (TYPE_CONTEXT (t) == NULL_TREE, 0); my_friendly_assert (TYPE_CONTEXT (t) == NULL_TREE, 0);
/* Substitue the return type. */ /* Substitue the return type. */
...@@ -6210,6 +6185,11 @@ tsubst (t, args, complain, in_decl) ...@@ -6210,6 +6185,11 @@ tsubst (t, args, complain, in_decl)
if (max == error_mark_node) if (max == error_mark_node)
return error_mark_node; return error_mark_node;
/* See if we can reduce this expression to something simpler. */
max = maybe_fold_nontype_arg (max);
if (!processing_template_decl && TREE_READONLY_DECL_P (max))
max = decl_constant_value (max);
if (processing_template_decl if (processing_template_decl
/* When providing explicit arguments to a template /* When providing explicit arguments to a template
function, but leaving some arguments for subsequent function, but leaving some arguments for subsequent
...@@ -6217,8 +6197,11 @@ tsubst (t, args, complain, in_decl) ...@@ -6217,8 +6197,11 @@ tsubst (t, args, complain, in_decl)
not PROCESSING_TEMPLATE_DECL. */ not PROCESSING_TEMPLATE_DECL. */
|| TREE_CODE (max) != INTEGER_CST) || TREE_CODE (max) != INTEGER_CST)
{ {
return build_index_type (build_min tree itype = make_node (INTEGER_TYPE);
(MINUS_EXPR, sizetype, max, integer_one_node)); TYPE_MIN_VALUE (itype) = size_zero_node;
TYPE_MAX_VALUE (itype) = build_min (MINUS_EXPR, sizetype, max,
integer_one_node);
return itype;
} }
if (integer_zerop (omax)) if (integer_zerop (omax))
...@@ -7124,22 +7107,19 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7124,22 +7107,19 @@ tsubst_expr (t, args, complain, in_decl)
case DECL_STMT: case DECL_STMT:
{ {
int i = suspend_momentary (); int i = suspend_momentary ();
tree decl, init; tree dcl, init;
lineno = STMT_LINENO (t); lineno = STMT_LINENO (t);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
decl = DECL_STMT_DECL (t); dcl = start_decl
init = DECL_INITIAL (decl); (tsubst (TREE_OPERAND (t, 0), args, complain, in_decl),
decl = tsubst (decl, args, complain, in_decl); tsubst (TREE_OPERAND (t, 1), args, complain, in_decl),
init = tsubst_expr (init, args, complain, in_decl); TREE_OPERAND (t, 2) != 0, NULL_TREE, NULL_TREE);
DECL_INITIAL (decl) = init; init = tsubst_expr (TREE_OPERAND (t, 2), args, complain, in_decl);
maybe_push_decl (decl); cp_finish_decl
if (TREE_CODE (decl) == VAR_DECL) (dcl, init, NULL_TREE, 1, /*init ? LOOKUP_ONLYCONVERTING :*/ 0);
DECL_TEMPLATE_INSTANTIATED (decl) = 1;
start_decl_1 (decl);
cp_finish_decl (decl, init, NULL_TREE, 0, 0);
resume_momentary (i); resume_momentary (i);
return decl; return dcl;
} }
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