re PR c++/13797 (ICE on invalid template parameter)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sun, 25 Jan 2004 14:18:19 +0000 (14:18 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sun, 25 Jan 2004 14:18:19 +0000 (14:18 +0000)
PR c++/13797
* pt.c (instantiate_class_template): Add an error_mark_node
check.
(tsubst_decl) <TEMPLATE_DECL case>: Likewise.

* g++.dg/template/nontype4.C: New test.
* g++.dg/template/nontype5.C: Likewise.

From-SVN: r76556

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/nontype4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/nontype5.C [new file with mode: 0644]

index be30e82..fdb396f 100644 (file)
@@ -1,3 +1,10 @@
+2003-01-25  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/13797
+       * pt.c (instantiate_class_template): Add an error_mark_node
+       check.
+       (tsubst_decl) <TEMPLATE_DECL case>: Likewise.
+
 2004-01-23  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c++/13701
index 967e9d1..2178e90 100644 (file)
@@ -5370,7 +5370,9 @@ instantiate_class_template (tree type)
              tree newtag;
 
              newtag = tsubst (tag, args, tf_error, NULL_TREE);
-             my_friendly_assert (newtag != error_mark_node, 20010206);
+             if (newtag == error_mark_node)
+               continue;
+
              if (TREE_CODE (newtag) != ENUMERAL_TYPE)
                {
                  if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag))
@@ -5902,6 +5904,9 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
        if (TREE_CODE (decl) == TYPE_DECL)
          {
            tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+           if (new_type == error_mark_node)
+             return error_mark_node;
+
            TREE_TYPE (r) = new_type;
            CLASSTYPE_TI_TEMPLATE (new_type) = r;
            DECL_TEMPLATE_RESULT (r) = TYPE_MAIN_DECL (new_type);
index c7935a4..0fd27b1 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-25  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/13797
+       * g++.dg/template/nontype4.C: New test.
+       * g++.dg/template/nontype5.C: Likewise.
+
 2004-01-25  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcc.dg/torture/mips-clobber-at.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/nontype4.C b/gcc/testsuite/g++.dg/template/nontype4.C
new file mode 100644 (file)
index 0000000..43ef2b0
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// Origin: Ivan Godard <igodard@pacbell.net>
+//        Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/13797: ICE invalid nontype template parameter
+
+template <int> struct A
+{
+    typedef A<0> B;            // { dg-error "not a valid type|conflict" }
+    template <B> struct B {};  // { dg-error "not a valid type|declaration" }
+};
+
+A<0> a;                                // { dg-error "instantiated" }
diff --git a/gcc/testsuite/g++.dg/template/nontype5.C b/gcc/testsuite/g++.dg/template/nontype5.C
new file mode 100644 (file)
index 0000000..e53b6c1
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// Origin: Ivan Godard <igodard@pacbell.net>
+//        Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/13797: ICE invalid nontype template parameter
+
+template <int> struct A
+{
+    typedef A<0> B;
+    template <B> struct C {};  // { dg-error "not a valid type" }
+};
+
+A<0> a;                                // { dg-error "instantiated" }