Commit bf8f3f93 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (determine_specialization): Don't declare.

	* cp-tree.h (determine_specialization): Don't declare.
	* pt.c (determine_specialization): Make it static.  Eliminate
	complain parameter.  Note that decl is always non-NULL now, and
	simplify accordingly.

From-SVN: r25554
parent 642b32a5
1999-03-02 Mark Mitchell <mark@markmitchell.com> 1999-03-02 Mark Mitchell <mark@markmitchell.com>
* cp-tree.h (determine_specialization): Don't declare.
* pt.c (determine_specialization): Make it static. Eliminate
complain parameter. Note that decl is always non-NULL now, and
simplify accordingly.
* decl.c (maybe_push_to_top_level): Always call * decl.c (maybe_push_to_top_level): Always call
push_cp_function_context. push_cp_function_context.
(pop_from_top_level): Always call pop_cp_function_context. (pop_from_top_level): Always call pop_cp_function_context.
......
...@@ -3053,7 +3053,6 @@ extern void reset_specialization PROTO((void)); ...@@ -3053,7 +3053,6 @@ extern void reset_specialization PROTO((void));
extern void end_specialization PROTO((void)); extern void end_specialization PROTO((void));
extern void begin_explicit_instantiation PROTO((void)); extern void begin_explicit_instantiation PROTO((void));
extern void end_explicit_instantiation PROTO((void)); extern void end_explicit_instantiation PROTO((void));
extern tree determine_specialization PROTO((tree, tree, tree *, int, int));
extern tree check_explicit_specialization PROTO((tree, tree, int, int)); extern tree check_explicit_specialization PROTO((tree, tree, int, int));
extern tree process_template_parm PROTO((tree, tree)); extern tree process_template_parm PROTO((tree, tree));
extern tree end_template_parm_list PROTO((tree)); extern tree end_template_parm_list PROTO((tree));
......
...@@ -148,6 +148,7 @@ static tree get_template_base PROTO((tree, tree, tree, tree)); ...@@ -148,6 +148,7 @@ static tree get_template_base PROTO((tree, tree, tree, tree));
static tree try_class_unification PROTO((tree, tree, tree, tree)); static tree try_class_unification PROTO((tree, tree, tree, tree));
static int coerce_template_template_parms PROTO((tree, tree, int, static int coerce_template_template_parms PROTO((tree, tree, int,
tree, tree)); tree, tree));
static tree determine_specialization PROTO((tree, tree, tree *, int));
/* We use TREE_VECs to hold template arguments. If there is only one /* We use TREE_VECs to hold template arguments. If there is only one
level of template arguments, then the TREE_VEC contains the level of template arguments, then the TREE_VEC contains the
...@@ -917,18 +918,15 @@ print_candidates (fns) ...@@ -917,18 +918,15 @@ print_candidates (fns)
are output in a newly created vector *TARGS_OUT. are output in a newly created vector *TARGS_OUT.
If it is impossible to determine the result, an error message is If it is impossible to determine the result, an error message is
issued, unless COMPLAIN is 0. In any case, error_mark_node is issued. The error_mark_node is returned to indicate failure. */
returned to indicate failure. */
tree tree
determine_specialization (template_id, decl, targs_out, determine_specialization (template_id, decl, targs_out,
need_member_template, need_member_template)
complain)
tree template_id; tree template_id;
tree decl; tree decl;
tree* targs_out; tree* targs_out;
int need_member_template; int need_member_template;
int complain;
{ {
tree fn; tree fn;
tree fns; tree fns;
...@@ -973,10 +971,6 @@ determine_specialization (template_id, decl, targs_out, ...@@ -973,10 +971,6 @@ determine_specialization (template_id, decl, targs_out,
/* This is just an ordinary non-member function. Nothing can /* This is just an ordinary non-member function. Nothing can
be a specialization of that. */ be a specialization of that. */
continue; continue;
else if (!decl)
/* When there's no DECL to match, we know we're looking for
non-members. */
continue;
else else
{ {
tree decl_arg_types; tree decl_arg_types;
...@@ -1010,25 +1004,12 @@ determine_specialization (template_id, decl, targs_out, ...@@ -1010,25 +1004,12 @@ determine_specialization (template_id, decl, targs_out,
continue; continue;
} }
if (decl == NULL_TREE)
{
/* Unify against ourselves to make sure that the args we have
make sense and there aren't any undeducible parms. It's OK if
not all the parms are specified; they might be deduced
later. */
targs = get_bindings_overload (tmpl, DECL_RESULT (tmpl),
explicit_targs);
if (uses_template_parms (targs))
/* We couldn't deduce all the arguments. */
continue;
}
else
/* See whether this function might be a specialization of this /* See whether this function might be a specialization of this
template. */ template. */
targs = get_bindings (tmpl, decl, explicit_targs); targs = get_bindings (tmpl, decl, explicit_targs);
if (!targs) if (!targs)
/* Wwe cannot deduce template arguments that when used to /* We cannot deduce template arguments that when used to
specialize TMPL will produce DECL. */ specialize TMPL will produce DECL. */
continue; continue;
...@@ -1036,7 +1017,7 @@ determine_specialization (template_id, decl, targs_out, ...@@ -1036,7 +1017,7 @@ determine_specialization (template_id, decl, targs_out,
templates = scratch_tree_cons (targs, tmpl, templates); templates = scratch_tree_cons (targs, tmpl, templates);
} }
if (decl && templates && TREE_CHAIN (templates)) if (templates && TREE_CHAIN (templates))
{ {
/* We have: /* We have:
...@@ -1079,21 +1060,18 @@ determine_specialization (template_id, decl, targs_out, ...@@ -1079,21 +1060,18 @@ determine_specialization (template_id, decl, targs_out,
if (templates == NULL_TREE && candidates == NULL_TREE) if (templates == NULL_TREE && candidates == NULL_TREE)
{ {
if (complain)
cp_error_at ("template-id `%D' for `%+D' does not match any template declaration", cp_error_at ("template-id `%D' for `%+D' does not match any template declaration",
template_id, decl); template_id, decl);
return error_mark_node; return error_mark_node;
} }
else if ((templates && TREE_CHAIN (templates)) else if ((templates && TREE_CHAIN (templates))
|| (candidates && TREE_CHAIN (candidates))) || (candidates && TREE_CHAIN (candidates))
{ || (templates && candidates))
if (complain)
{ {
cp_error_at ("ambiguous template specialization `%D' for `%+D'", cp_error_at ("ambiguous template specialization `%D' for `%+D'",
template_id, decl); template_id, decl);
chainon (candidates, templates); chainon (candidates, templates);
print_candidates (candidates); print_candidates (candidates);
}
return error_mark_node; return error_mark_node;
} }
...@@ -1445,8 +1423,7 @@ check_explicit_specialization (declarator, decl, template_count, flags) ...@@ -1445,8 +1423,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
declaration. */ declaration. */
tmpl = determine_specialization (declarator, decl, tmpl = determine_specialization (declarator, decl,
&targs, &targs,
member_specialization, member_specialization);
1);
if (!tmpl || tmpl == error_mark_node) if (!tmpl || tmpl == error_mark_node)
/* We couldn't figure out what this declaration was /* We couldn't figure out what this declaration was
...@@ -4366,8 +4343,7 @@ tsubst_friend_function (decl, args) ...@@ -4366,8 +4343,7 @@ tsubst_friend_function (decl, args)
new_friend = tsubst (decl, args, /*complain=*/1, NULL_TREE); new_friend = tsubst (decl, args, /*complain=*/1, NULL_TREE);
tmpl = determine_specialization (template_id, new_friend, tmpl = determine_specialization (template_id, new_friend,
&new_args, &new_args,
/*need_member_template=*/0, /*need_member_template=*/0);
/*complain=*/1);
new_friend = instantiate_template (tmpl, new_args); new_friend = instantiate_template (tmpl, new_args);
goto done; goto done;
} }
...@@ -6409,6 +6385,15 @@ tsubst (t, args, complain, in_decl) ...@@ -6409,6 +6385,15 @@ tsubst (t, args, complain, in_decl)
if (ctx == error_mark_node || f == error_mark_node) if (ctx == error_mark_node || f == error_mark_node)
return error_mark_node; return error_mark_node;
if (!IS_AGGR_TYPE (ctx))
{
if (complain)
cp_error ("`%T' is not a class, struct, or union type",
ctx);
return error_mark_node;
}
else if (!uses_template_parms (ctx) && !TYPE_BEING_DEFINED (ctx))
{
/* Normally, make_typename_type does not require that the CTX /* Normally, make_typename_type does not require that the CTX
have complete type in order to allow things like: have complete type in order to allow things like:
...@@ -6417,8 +6402,6 @@ tsubst (t, args, complain, in_decl) ...@@ -6417,8 +6402,6 @@ tsubst (t, args, complain, in_decl)
But, such constructs have already been resolved by this But, such constructs have already been resolved by this
point, so here CTX really should have complete type, unless point, so here CTX really should have complete type, unless
it's a partial instantiation. */ it's a partial instantiation. */
if (!uses_template_parms (ctx) && !TYPE_BEING_DEFINED (ctx))
{
ctx = complete_type (ctx); ctx = complete_type (ctx);
if (!TYPE_SIZE (ctx)) if (!TYPE_SIZE (ctx))
{ {
......
// Build don't link:
extern "C" int printf(const char *, ...);
template <class T> struct A {
typedef typename T::X B; // ERROR - not a class
A(double);
};
template <class T> void xxx(typename A<T>::B);
template <class T> struct B {
friend void xxx<T>(T); // ERROR - does not match any template
};
template struct B<double>; // ERROR -
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