extern tree push_template_decl PARAMS ((tree));
extern tree push_template_decl_real PARAMS ((tree, int));
extern void redeclare_class_template PARAMS ((tree, tree));
-extern tree lookup_template_class PARAMS ((tree, tree, tree, tree, int));
+extern tree lookup_template_class PARAMS ((tree, tree, tree, tree, int, int));
extern tree lookup_template_function PARAMS ((tree, tree));
extern int uses_template_parms PARAMS ((tree));
extern tree instantiate_class_template PARAMS ((tree));
If ENTERING_SCOPE is non-zero, we are about to enter the scope of
the class we are looking up.
+
+ If COMPLAIN is non-zero, issue error messages.
If the template class is really a local class in a template
function, then the FUNCTION_CONTEXT is the function in which it is
being instantiated. */
tree
-lookup_template_class (d1, arglist, in_decl, context, entering_scope)
+lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
tree d1, arglist;
tree in_decl;
tree context;
int entering_scope;
+ int complain;
{
tree template = NULL_TREE, parmlist;
tree t;
crash. Alternatively D1 might not be a template type at all. */
if (! template)
{
- cp_error ("`%T' is not a template", d1);
+ if (complain)
+ cp_error ("`%T' is not a template", d1);
return error_mark_node;
}
if (TREE_CODE (template) != TEMPLATE_DECL)
{
- cp_error ("non-template type `%T' used as a template", d1);
- if (in_decl)
- cp_error_at ("for template declaration `%D'", in_decl);
+ if (complain)
+ {
+ cp_error ("non-template type `%T' used as a template", d1);
+ if (in_decl)
+ cp_error_at ("for template declaration `%D'", in_decl);
+ }
return error_mark_node;
}
parmlist = DECL_INNERMOST_TEMPLATE_PARMS (template);
- arglist2 = coerce_template_parms (parmlist, arglist, template, 1, 1);
+ arglist2 = coerce_template_parms (parmlist, arglist, template,
+ complain, /*require_all_args=*/1);
if (arglist2 == error_mark_node)
return error_mark_node;
--i, t = TREE_CHAIN (t))
{
tree a = coerce_template_parms (TREE_VALUE (t),
- arglist, template, 1, 1);
+ arglist, template,
+ complain, /*require_all_args=*/1);
SET_TMPL_ARGS_LEVEL (bound_args, i, a);
/* We temporarily reduce the length of the ARGLIST so
arglist
= coerce_template_parms (INNERMOST_TEMPLATE_PARMS (parmlist),
INNERMOST_TEMPLATE_ARGS (arglist),
- template, 1, 1);
+ template,
+ complain, /*require_all_args=*/1);
if (arglist == error_mark_node)
/* We were unable to bind the arguments. */
return error_mark_node;
r = lookup_template_class (t, argvec, in_decl, context,
- entering_scope);
+ entering_scope, complain);
return cp_build_qualified_type_real (r, TYPE_QUALS (t),
complain);
r = lookup_template_class (arg,
argvec, in_decl,
DECL_CONTEXT (arg),
- /*entering_scope=*/0);
+ /*entering_scope=*/0,
+ complain);
return cp_build_qualified_type_real (r,
TYPE_QUALS (t),
complain);
--- /dev/null
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com>
+
+// Bug 1694. We complained during deduction, rather than reject the deduction.
+
+template <class T, T d> class X {};
+
+template <class T> X<T,0> Foo (T *);
+template <class T> int Foo (T const *);
+
+void Baz (int *p1, int const *p2)
+{
+ int i = Foo (p1); // ERROR - cannot convert
+ int j = Foo (p2);
+}
+void Baz (float *p1, float const *p2)
+{
+ int i = Foo (p1); // ok, deduction fails on X<T,0> Foo (T *)
+ int j = Foo (p2);
+}