Commit 73aad9b9 by Jason Merrill Committed by Mike Stump

87th Cygnus<->FSF quick merge

From-SVN: r12630
parent c8c2dcdc
Mon Aug 12 00:09:18 1996 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (end_template_decl): If we don't actually have parms, return.
* parse.y (template_header): Accept 'template <>'.
* errfn.c: Allow 5 args.
Sun Aug 11 15:20:58 1996 Jason Merrill <jason@yorick.cygnus.com>
* tree.c (make_temp_vec): New fn.
* pt.c (push_template_decl): Handle partial specs.
(instantiate_class_template): Ditto.
(more_specialized): Use get_bindings.
(more_specialized_class): New fn.
(get_class_bindings): New fn.
(most_specialized_class): New fn.
(do_function_instantiation): List candidates for ambiguous case.
* decl.c (duplicate_decls): Lose reference to DECL_TEMPLATE_MEMBERS.
(shadow_tag): Call push_template_decl for partial specializations.
* parse.y: Ditto.
* cp-tree.h (DECL_TEMPLATE_SPECIALIZATIONS): Replaces
DECL_TEMPLATE_MEMBERS.
* call.c (print_z_candidates): Reduce duplication.
Fri Aug 9 14:36:08 1996 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (lang_decode_option): Allow -fansi-overloading.
Thu Aug 8 17:04:18 1996 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (get_bindings): New fn.
(most_specialized): Ditto.
(do_function_instantiation): Use them.
(add_maybe_template): New fn.
* cp-tree.h (DECL_MAYBE_TEMPLATE): New macro.
* call.c (build_new_op): Handle guiding decls.
(build_new_function_call): Ditto.
* decl2.c (finish_file): Ditto.
* decl2.c (mark_used): Do synthesis here.
* call.c (build_method_call): Not here.
(build_over_call): Or here.
* typeck.c (build_function_call_real): Or here.
* tree.c (bot_manip): Call mark_used on functions used in default
args.
Thu Aug 8 17:48:16 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* decl2.c (import_export_vtable): Delete code that disabled vtable
......
......@@ -2468,12 +2468,6 @@ build_method_call (instance, name, parms, basetype_path, flags)
function = DECL_MAIN_VARIANT (function);
mark_used (function);
/* Is it a synthesized method that needs to be synthesized? */
if (DECL_ARTIFICIAL (function) && ! DECL_INITIAL (function)
/* Kludge: don't synthesize for default args. */
&& current_function_decl)
synthesize_method (function);
if (pedantic && DECL_THIS_INLINE (function) && ! DECL_ARTIFICIAL (function)
&& ! DECL_INITIAL (function) && ! DECL_PENDING_INLINE_INFO (function)
&& ! (DECL_TEMPLATE_INFO (function)
......@@ -4157,48 +4151,27 @@ static void
print_z_candidates (candidates)
struct z_candidate *candidates;
{
if (! candidates)
return;
if (TREE_CODE (candidates->fn) == IDENTIFIER_NODE)
{
if (candidates->fn == ansi_opname [COND_EXPR])
cp_error ("candidates are: %D(%T, %T, %T) <builtin>", candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 2)));
else if (TREE_VEC_LENGTH (candidates->convs) == 2)
cp_error ("candidates are: %D(%T, %T) <builtin>", candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)));
else
cp_error ("candidates are: %D(%T) <builtin>", candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)));
}
else
cp_error_at ("candidates are: %D", candidates->fn);
candidates = candidates->next;
char *str = "candidates are:";
for (; candidates; candidates = candidates->next)
{
if (TREE_CODE (candidates->fn) == IDENTIFIER_NODE)
{
if (candidates->fn == ansi_opname [COND_EXPR])
cp_error (" %D(%T, %T, %T) <builtin>",
candidates->fn,
cp_error ("%s %D(%T, %T, %T) <builtin>", str, candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 2)));
else if (TREE_VEC_LENGTH (candidates->convs) == 2)
cp_error (" %D(%T, %T) <builtin>", candidates->fn,
cp_error ("%s %D(%T, %T) <builtin>", str, candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)),
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)));
else
cp_error (" %D(%T) <builtin>", candidates->fn,
cp_error ("%s %D(%T) <builtin>", str, candidates->fn,
TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)));
}
else
cp_error_at (" %D", candidates->fn);
cp_error_at ("%s %+D", str, candidates->fn);
str = " ";
}
}
......@@ -4334,6 +4307,7 @@ build_new_function_call (fn, args, obj)
if (obj == NULL_TREE && TREE_CODE (fn) == TREE_LIST)
{
tree t;
tree templates = NULL_TREE;
for (t = args; t; t = TREE_CHAIN (t))
if (TREE_VALUE (t) == error_mark_node)
......@@ -4342,8 +4316,11 @@ build_new_function_call (fn, args, obj)
for (t = TREE_VALUE (fn); t; t = DECL_CHAIN (t))
{
if (TREE_CODE (t) == TEMPLATE_DECL)
{
templates = decl_tree_cons (NULL_TREE, t, templates);
candidates = add_template_candidate
(candidates, t, args, LOOKUP_NORMAL);
}
else
candidates = add_function_candidate
(candidates, t, args, LOOKUP_NORMAL);
......@@ -4369,6 +4346,12 @@ build_new_function_call (fn, args, obj)
return error_mark_node;
}
/* Pedantically, it is ill-formed to define a function that could
also be a template instantiation, but we won't implement that
until things settle down. */
if (templates && ! cand->template && ! DECL_INITIAL (cand->fn))
add_maybe_template (cand->fn, templates);
return build_over_call (cand->fn, cand->convs, args, LOOKUP_NORMAL);
}
......@@ -4482,6 +4465,7 @@ build_new_op (code, flags, arg1, arg2, arg3)
struct z_candidate *candidates = 0, *cand;
tree fns, mem_arglist, arglist, fnname, *p;
enum tree_code code2 = NOP_EXPR;
tree templates = NULL_TREE;
if (arg1 == error_mark_node)
return error_mark_node;
......@@ -4602,7 +4586,11 @@ build_new_op (code, flags, arg1, arg2, arg3)
for (; fns; fns = DECL_CHAIN (fns))
{
if (TREE_CODE (fns) == TEMPLATE_DECL)
candidates = add_template_candidate (candidates, fns, arglist, flags);
{
templates = decl_tree_cons (NULL_TREE, fns, templates);
candidates = add_template_candidate
(candidates, fns, arglist, flags);
}
else
candidates = add_function_candidate (candidates, fns, arglist, flags);
}
......@@ -4715,6 +4703,13 @@ build_new_op (code, flags, arg1, arg2, arg3)
if (DECL_FUNCTION_MEMBER_P (cand->fn))
enforce_access (cand->basetype_path, cand->fn);
/* Pedantically, it is ill-formed to define a function that could
also be a template instantiation, but we won't implement that
until things settle down. */
if (templates && ! cand->template && ! DECL_INITIAL (cand->fn)
&& TREE_CODE (TREE_TYPE (cand->fn)) != METHOD_TYPE)
add_maybe_template (cand->fn, templates);
return build_over_call
(cand->fn, cand->convs,
TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE
......@@ -4999,12 +4994,6 @@ build_over_call (fn, convs, args, flags)
converted_args = nreverse (converted_args);
mark_used (fn);
/* Is it a synthesized method that needs to be synthesized? */
if (DECL_ARTIFICIAL (fn) && ! DECL_INITIAL (fn)
&& DECL_CLASS_CONTEXT (fn)
/* Kludge: don't synthesize for default args. */
&& current_function_decl)
synthesize_method (fn);
if (pedantic && DECL_THIS_INLINE (fn) && ! DECL_ARTIFICIAL (fn)
&& ! DECL_INITIAL (fn) && ! DECL_PENDING_INLINE_INFO (fn)
......
......@@ -1135,7 +1135,7 @@ struct lang_decl
#if 0 /* UNUSED */
/* Nonzero in IDENTIFIER_NODE means that this name is overloaded, and
should be looked up in a non-standard way. */
#define DECL_OVERLOADED(NODE) (DECL_LANG_FLAG_4 (NODE))
#define DECL_OVERLOADED(NODE) (FOO)
#endif
/* Nonzero if this (non-TYPE)_DECL has its virtual attribute set.
......@@ -1331,7 +1331,7 @@ extern int flag_new_for_scope;
/* Accessor macros for C++ template decl nodes. */
#define DECL_TEMPLATE_PARMS(NODE) DECL_ARGUMENTS(NODE)
/* For class templates. */
#define DECL_TEMPLATE_MEMBERS(NODE) DECL_SIZE(NODE)
#define DECL_TEMPLATE_SPECIALIZATIONS(NODE) DECL_SIZE(NODE)
/* For function, method, class-data templates. */
#define DECL_TEMPLATE_RESULT(NODE) DECL_RESULT(NODE)
#define DECL_TEMPLATE_INSTANTIATIONS(NODE) DECL_VINDEX(NODE)
......@@ -1380,6 +1380,8 @@ extern int flag_new_for_scope;
#define SET_CLASSTYPE_EXPLICIT_INSTANTIATION(NODE) \
(CLASSTYPE_USE_TEMPLATE(NODE) = 3)
/* This function may be a guiding decl for a template. */
#define DECL_MAYBE_TEMPLATE(NODE) DECL_LANG_FLAG_4 (NODE)
/* We know what we're doing with this decl now. */
#define DECL_INTERFACE_KNOWN(NODE) DECL_LANG_FLAG_5 (NODE)
......@@ -2308,6 +2310,7 @@ extern tree instantiate_decl PROTO((tree));
extern tree classtype_mangled_name PROTO((tree));
extern tree lookup_nested_type_by_name PROTO((tree, tree));
extern tree do_poplevel PROTO((void));
extern tree *get_bindings PROTO((tree, tree));
/* in search.c */
extern void push_memoized_context PROTO((tree, int));
......
......@@ -2869,7 +2869,6 @@ duplicate_decls (newdecl, olddecl)
if (TREE_CODE (newdecl) == TEMPLATE_DECL)
{
DECL_TEMPLATE_MEMBERS (newdecl) = DECL_TEMPLATE_MEMBERS (olddecl);
DECL_TEMPLATE_INSTANTIATIONS (newdecl)
= DECL_TEMPLATE_INSTANTIATIONS (olddecl);
if (DECL_CHAIN (newdecl) == NULL_TREE)
......@@ -5646,7 +5645,11 @@ shadow_tag (declspecs)
{
if (CLASSTYPE_IMPLICIT_INSTANTIATION (value)
&& TYPE_SIZE (value) == NULL_TREE)
{
SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (value);
if (current_template_parms)
push_template_decl (TYPE_MAIN_DECL (value));
}
else if (CLASSTYPE_TEMPLATE_INSTANTIATION (value))
cp_error ("specialization after instantiation of `%T'", value);
}
......
......@@ -498,11 +498,6 @@ lang_decode_option (p)
flag_alt_external_templates = 0;
found = 1;
}
else if (!strcmp (p, "ansi-overloading"))
{
warning ("-fansi-overloading is no longer meaningful");
found = 1;
}
else if (!strcmp (p, "repo"))
{
flag_use_repository = 1;
......@@ -2876,6 +2871,7 @@ build_cleanup (decl)
extern int parse_time, varconst_time;
extern tree pending_templates;
extern tree maybe_templates;
#define TIMEVAR(VAR, BODY) \
do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
......@@ -2952,6 +2948,20 @@ finish_file ()
instantiate_decl (decl);
}
for (fnname = maybe_templates; fnname; fnname = TREE_CHAIN (fnname))
{
tree *args, fn, decl = TREE_VALUE (fnname);
if (DECL_INITIAL (decl))
continue;
fn = TREE_PURPOSE (fnname);
args = get_bindings (fn, decl);
fn = instantiate_template (fn, args);
free (args);
instantiate_decl (fn);
}
/* Push into C language context, because that's all
we'll need here. */
push_lang_context (lang_name_c);
......@@ -3848,6 +3858,12 @@ mark_used (decl)
if (current_template_parms)
return;
assemble_external (decl);
/* Is it a synthesized method that needs to be synthesized? */
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_CLASS_CONTEXT (decl)
&& DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
/* Kludge: don't synthesize for default args. */
&& current_function_decl)
synthesize_method (decl);
if (DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl))
instantiate_decl (decl);
}
......@@ -44,11 +44,12 @@ extern int cp_line_of PROTO((tree));
#define STRDUP(f) (ap = (char *) alloca (strlen (f) +1), strcpy (ap, (f)), ap)
#define NARGS 4
#define arglist a1, a2, a3, a4
#define arglist_dcl HOST_WIDE_INT a1, a2, a3, a4;
#define ARGSINIT args[0] = a1; args[1] = a2; args[2] = a3; args[3] = a4;
#define ARGSLIST args[0], args[1], args[2], args[3]
#define NARGS 5
#define arglist a1, a2, a3, a4, a5
#define arglist_dcl HOST_WIDE_INT a1, a2, a3, a4, a5;
#define ARGSINIT \
args[0] = a1; args[1] = a2; args[2] = a3; args[3] = a4; args[4] = a5;
#define ARGSLIST args[0], args[1], args[2], args[3], args[4]
static void
cp_thing (errfn, atarg1, format, arglist)
......
......@@ -418,6 +418,8 @@ template_header:
{ begin_template_parm_list (); }
template_parm_list '>'
{ $$ = end_template_parm_list ($4); }
| TEMPLATE '<' '>'
{ $$ = NULL_TREE; }
;
template_parm_list:
......@@ -2321,7 +2323,11 @@ named_class_head:
{
if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
&& TYPE_SIZE ($$) == NULL_TREE)
{
SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
if (current_template_parms)
push_template_decl (TYPE_MAIN_DECL ($$));
}
else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
cp_error ("specialization after instantiation of `%T'", $$);
}
......@@ -2525,7 +2531,11 @@ left_curly: '{'
{
if (CLASSTYPE_IMPLICIT_INSTANTIATION (t)
&& TYPE_SIZE (t) == NULL_TREE)
{
SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
if (current_template_parms)
push_template_decl (TYPE_MAIN_DECL (t));
}
else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
cp_error ("specialization after instantiation of `%T'", t);
}
......
......@@ -1772,8 +1772,21 @@ bot_manip (t)
if (TREE_CODE (t) != TREE_LIST && ! TREE_SIDE_EFFECTS (t))
return t;
else if (TREE_CODE (t) == TARGET_EXPR)
return build_cplus_new (TREE_TYPE (t),
break_out_target_exprs (TREE_OPERAND (t, 1)));
{
if (TREE_CODE (TREE_OPERAND (t, 1)) == NEW_EXPR)
{
mark_used (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 1), 0), 0));
return build_cplus_new
(TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
}
t = copy_node (t);
TREE_OPERAND (t, 0) = build (VAR_DECL, TREE_TYPE (t));
layout_decl (TREE_OPERAND (t, 0), 0);
return t;
}
else if (TREE_CODE (t) == CALL_EXPR)
mark_used (TREE_OPERAND (TREE_OPERAND (t, 0), 0));
return NULL_TREE;
}
......@@ -2078,3 +2091,17 @@ cp_tree_equal (t1, t2)
return -1;
}
/* Similar to make_tree_vec, but build on a temporary obstack. */
tree
make_temp_vec (len)
int len;
{
register tree node;
push_obstacks_nochange ();
resume_temporary_allocation ();
node = make_tree_vec (len);
pop_obstacks ();
return node;
}
......@@ -2545,15 +2545,7 @@ build_function_call_real (function, params, require_complete, flags)
needs to be separately compiled). */
if (DECL_INLINE (function))
{
/* Is it a synthesized method that needs to be synthesized? */
if (DECL_ARTIFICIAL (function) && ! DECL_INITIAL (function)
/* Kludge: don't synthesize for default args. */
&& current_function_decl)
synthesize_method (function);
function = inline_conversion (function);
}
else
function = build_addr_func (function);
}
......
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