]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13797 (ICE on invalid template parameter)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sun, 25 Jan 2004 15:08:20 +0000 (15:08 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sun, 25 Jan 2004 15:08:20 +0000 (15:08 +0000)
PR c++/13797
* pt.c (instantiate_class_template): Add an error_mark_node
check.
(tsubst_decl) <TEMPLATE_DECL case>: Likewise.

Backport from mainline
2003-05-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

PR c++/10555, c++/10576
* pt.c (lookup_template_class): Handle class template with
multiple levels of parameters when one of the levels contain
errors.

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

From-SVN: r76562

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/memclass1.C

index 225c02d5cf4301d5fadf478006e932db7db1bd56..b7511b3d914f28252bcde95e0335f34ce2266645 100644 (file)
@@ -1,3 +1,18 @@
+2004-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.
+
+       Backport from mainline
+       2003-05-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/10555, c++/10576
+       * pt.c (lookup_template_class): Handle class template with
+       multiple levels of parameters when one of the levels contain
+       errors.
+
 2004-01-21  Gabriel Dos Reis <gdr@integrable-solutions.net>
 
        Backport from mainline
index e64ed166b3e34d27e537562407911f0074f42fb4..0caecaf4cae69896cad975f70d80d63b6e961fbd 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle parameterized types (templates) for GNU C++.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002  Free Software Foundation, Inc.
+   2001, 2002, 2004  Free Software Foundation, Inc.
    Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
    Rewritten by Jason Merrill (jason@cygnus.com).
 
@@ -4255,6 +4255,15 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
              tree a = coerce_template_parms (TREE_VALUE (t),
                                              arglist, template,
                                              complain, /*require_all_args=*/1);
+
+             /* Don't process further if one of the levels fails.  */
+             if (a == error_mark_node)
+               {
+                 /* Restore the ARGLIST to its full size.  */
+                 TREE_VEC_LENGTH (arglist) = saved_depth;
+                 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
+               }
+             
              SET_TMPL_ARGS_LEVEL (bound_args, i, a);
 
              /* We temporarily reduce the length of the ARGLIST so
@@ -5462,7 +5471,9 @@ instantiate_class_template (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))
@@ -6001,6 +6012,9 @@ tsubst_decl (t, args, type, 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 f60b1c350381b3e15fe1349bc83b674844b29ff9..866586168a8086f712fdf6d6226788daf1c0a072 100644 (file)
@@ -1,3 +1,12 @@
+2004-01-25  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/13797
+       * g++.dg/template/nontype4.C: New test.
+       * g++.dg/template/nontype5.C: Likewise.
+
+       PR c++/10555, c++/10576
+       * g++.dg/template/memclass1.C: New test.
+
 2004-01-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/13392
index c49ed724d6f7d77a5be6f63a4b4b7ad238e1401b..65921b31337df983dd403907e61acdd41f8c9388 100644 (file)
@@ -12,7 +12,7 @@ template <typename> struct A
 
 template <typename T> struct C
 {
-    typedef typename A<T>::template B<U> X; // { dg-error "declared|invalid" }
+    typedef typename A<T>::template B<U> X; // { dg-error "mismatch|expected" }
 };
 
-C<void> c;
+C<void> c;                     // { dg-error "instantiated" }