aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-01-19 09:24:20 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-01-19 09:24:20 +0000
commitf9c244b8a482a2c13af8e1b9e959010e01d374a4 (patch)
treec096f6cbd10bc066542ce1544c8f0d20cf64addb /gcc
parent61f0131c68b026c24560d3b9adde5ab7c34c073c (diff)
downloadgcc-f9c244b8a482a2c13af8e1b9e959010e01d374a4.zip
gcc-f9c244b8a482a2c13af8e1b9e959010e01d374a4.tar.gz
gcc-f9c244b8a482a2c13af8e1b9e959010e01d374a4.tar.bz2
cp-tree.h (lookup_template_class): Add complain parm.
cp: * cp-tree.h (lookup_template_class): Add complain parm. * decl.c (lookup_namespace_name): Adjust call to lookup_template_class. (make_typename_type): Likewise. * semantics.c (finish_template_type): Likewise. * pt.c (lookup_template_class): Add complain parm. Adjust. (tsubst_aggr_type): Pass COMPLAIN down to lookup_template_class. (tsubst): Likewise. testsuite: * g++.old-deja/g++.pt/deduct3.C: New test. From-SVN: r39129
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/pt.c31
-rw-r--r--gcc/cp/semantics.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/deduct3.C22
7 files changed, 65 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9a262f1..69e7473 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,16 @@
2001-01-19 Nathan Sidwell <nathan@codesourcery.com>
+ * cp-tree.h (lookup_template_class): Add complain parm.
+ * decl.c (lookup_namespace_name): Adjust call to
+ lookup_template_class.
+ (make_typename_type): Likewise.
+ * semantics.c (finish_template_type): Likewise.
+ * pt.c (lookup_template_class): Add complain parm. Adjust.
+ (tsubst_aggr_type): Pass COMPLAIN down to lookup_template_class.
+ (tsubst): Likewise.
+
+2001-01-19 Nathan Sidwell <nathan@codesourcery.com>
+
* pt.c (copy_default_args_to_explicit_spec): Preserve
object's CV quals. Reorganize.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index eea27e0..1df938b 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4135,7 +4135,7 @@ extern tree current_template_args PARAMS ((void));
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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e5fd61e..158407c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5439,7 +5439,8 @@ lookup_namespace_name (namespace, name)
TREE_OPERAND (template_id, 1),
/*in_decl=*/NULL_TREE,
/*context=*/NULL_TREE,
- /*entering_scope=*/0);
+ /*entering_scope=*/0,
+ /*complain=*/1);
else if (DECL_FUNCTION_TEMPLATE_P (val)
|| TREE_CODE (val) == OVERLOAD)
val = lookup_template_function (val,
@@ -5623,7 +5624,8 @@ make_typename_type (context, name, complain)
return lookup_template_class (tmpl,
TREE_OPERAND (fullname, 1),
NULL_TREE, context,
- /*entering_scope=*/0);
+ /*entering_scope=*/0,
+ /*complain=*/1);
}
else
{
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 33c3f26..cf3b52d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3813,17 +3813,20 @@ maybe_get_template_decl_from_type_decl (decl)
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;
@@ -3881,15 +3884,19 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
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;
}
@@ -3903,7 +3910,8 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
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;
@@ -3971,7 +3979,8 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
--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
@@ -3990,7 +3999,8 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
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. */
@@ -5466,7 +5476,7 @@ tsubst_aggr_type (t, args, complain, in_decl, entering_scope)
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);
@@ -6426,7 +6436,8 @@ tsubst (t, args, complain, in_decl)
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);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0c4ed96..e52138b 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2032,7 +2032,8 @@ finish_template_type (name, args, entering_scope)
tree decl;
decl = lookup_template_class (name, args,
- NULL_TREE, NULL_TREE, entering_scope);
+ NULL_TREE, NULL_TREE,
+ entering_scope, /*complain=*/1);
if (decl != error_mark_node)
decl = TYPE_STUB_DECL (decl);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4ff2124..9c5b616 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2001-01-19 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.old-deja/g++.pt/deduct3.C: New test.
+
+2001-01-19 Nathan Sidwell <nathan@codesourcery.com>
+
* g++.old-deja/g++.pt/spec34.C: New test.
2001-01-19 "Billinghurst, David (CRTS)" <David.Billinghurst@riotinto.com>
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C
new file mode 100644
index 0000000..8b9b76e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C
@@ -0,0 +1,22 @@
+// 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);
+}