summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-16 13:43:50 +0000
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-16 13:43:50 +0000
commit66da0aecd2e6ed4b0c20bbaf377395a97ddac8f1 (patch)
tree0d515ec700acc964bbf182734d4b8ff0ec745571
parent664dca4d8af31783ad3d4d0d1b384b67a1f2ff3c (diff)
downloadgcc-66da0aecd2e6ed4b0c20bbaf377395a97ddac8f1.tar.gz
PR c++/6620
* pt.c (verify_class_unification): Don't check if PARM is template parameter dependent. Simplify. (unify) [TEMPLATE_PARM_INDEX]: Handle when ARG is a template parameter dependent expression. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53517 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/pt.c33
-rw-r--r--gcc/testsuite/g++.dg/template/partial1.C36
3 files changed, 54 insertions, 23 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0f5673e9cdc..3adedeb13f3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2002-05-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/6620
+ * pt.c (verify_class_unification): Don't check if PARM is template
+ parameter dependent. Simplify.
+ (unify) [TEMPLATE_PARM_INDEX]: Handle when ARG is a template
+ parameter dependent expression.
+
2002-05-14 Jason Merrill <jason@redhat.com>
* rtti.c (get_tinfo_decl): Don't call comdat_linkage.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c4e119e10cb..58fe3c57369 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8307,29 +8307,12 @@ static int
verify_class_unification (targs, parms, args)
tree targs, parms, args;
{
- int i;
- int nparms = TREE_VEC_LENGTH (parms);
- tree new_parms = tsubst (parms, add_outermost_template_args (args, targs),
- tf_none, NULL_TREE);
- if (new_parms == error_mark_node)
+ parms = tsubst (parms, add_outermost_template_args (args, targs),
+ tf_none, NULL_TREE);
+ if (parms == error_mark_node)
return 1;
- args = INNERMOST_TEMPLATE_ARGS (args);
-
- for (i = 0; i < nparms; i++)
- {
- tree parm = TREE_VEC_ELT (new_parms, i);
- tree arg = TREE_VEC_ELT (args, i);
-
- /* In case we are deducing from a function argument of a function
- templates, some parameters may not be deduced yet. So we
- make sure that only fully substituted elements of PARM are
- compared below. */
-
- if (!uses_template_parms (parm) && !template_args_equal (parm, arg))
- return 1;
- }
- return 0;
+ return !comp_template_args (parms, INNERMOST_TEMPLATE_ARGS (args));
}
/* PARM is a template class (perhaps with unbound template
@@ -8812,8 +8795,12 @@ unify (tparms, targs, parm, arg, strict)
deduced from an array bound may be of any integral type.
The non-type parameter might use already deduced type parameters. */
tparm = tsubst (TREE_TYPE (parm), targs, 0, NULL_TREE);
- if (same_type_p (TREE_TYPE (arg), tparm))
- /* OK */;
+ if (!TREE_TYPE (arg))
+ /* Template-parameter dependent expression. Just accept it for now.
+ It will later be processed in convert_template_argument. */
+ ;
+ else if (same_type_p (TREE_TYPE (arg), tparm))
+ /* OK */;
else if ((strict & UNIFY_ALLOW_INTEGER)
&& (TREE_CODE (tparm) == INTEGER_TYPE
|| TREE_CODE (tparm) == BOOLEAN_TYPE))
diff --git a/gcc/testsuite/g++.dg/template/partial1.C b/gcc/testsuite/g++.dg/template/partial1.C
new file mode 100644
index 00000000000..41ea5303969
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial1.C
@@ -0,0 +1,36 @@
+// { dg-do run }
+// Origin: Jo Totland <jototland@hotmail.com>
+
+// PR c++/6620
+// Partial specialization involving expression of non-type template
+// parameter causes ICE.
+
+extern "C" void abort();
+
+template <int N> struct HoldInt
+{
+};
+
+template <class A, class B> struct Add
+{
+};
+
+template <int N> struct Add<HoldInt<N>, HoldInt<-N> >
+{
+ typedef int type;
+ int f() { return 0; }
+};
+
+template <int N, int M>
+struct Add<HoldInt<N>, HoldInt<M> >
+{
+ typedef HoldInt<N+M> type;
+ int f() { return 1; }
+};
+
+int main() {
+ Add<HoldInt<1>, HoldInt<-1> > a;
+ Add<HoldInt<1>, HoldInt<-2> > b;
+ if (a.f() != 0 || b.f() != 1)
+ abort();
+}