]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/16716 (ICE in cp_parser_parse_and_diagnose_invalid_type_name)
authorMark Mitchell <mark@codesourcery.com>
Tue, 14 Sep 2004 00:29:03 +0000 (00:29 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 14 Sep 2004 00:29:03 +0000 (00:29 +0000)
PR c++/16716
* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
Robustify.

PR c++/17327
* pt.c (unify): Add ENUMERAL_TYPE case.  Replace sorry with
gcc_unreacable.

PR c++/16716
* g++.dg/parse/crash17.C: New test.

PR c++/17327
* g++.dg/template/enum3.C: New test.

From-SVN: r87467

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash17.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/enum3.C [new file with mode: 0644]

index 37f08119566f5377b9e1259ea39487240f533ab4..010320136ddc4141938070ff7fdb259216a1cfae 100644 (file)
@@ -1,3 +1,13 @@
+2004-09-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/16716
+       * parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
+       Robustify.
+
+       PR c++/17327
+       * pt.c (unify): Add ENUMERAL_TYPE case.  Replace sorry with
+       gcc_unreacable.
+
 2004-09-12  Richard Henderson  <rth@redhat.com>
 
        PR c++/16254
index 0f6821e546b31bee81a27e2bf6eb1354cb7cbe62..6ac5c717d3f21be9fb3f176ba7d20a5aa2b368e6 100644 (file)
@@ -2286,13 +2286,10 @@ cp_parser_parse_and_diagnose_invalid_type_name (cp_parser *parser)
       cp_parser_abort_tentative_parse (parser);
       return false;
     }
-  if (!cp_parser_parse_definitely (parser))
+  if (!cp_parser_parse_definitely (parser)
+      || TREE_CODE (id) != IDENTIFIER_NODE)
     return false;
 
-  /* If we got here, this cannot be a valid variable declaration, thus
-     the cp_parser_id_expression must have resolved to a plain identifier
-     node (not a TYPE_DECL or TEMPLATE_ID_EXPR).  */
-  gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
   /* Emit a diagnostic for the invalid type.  */
   cp_parser_diagnose_invalid_type_name (parser, parser->scope, id);
   /* Skip to the end of the declaration; there's no point in
index 0a6b773d1ad5368455b4b4eeae91b2a3aaa536dd..90efa06d7cc4ffd38fc4c6556ee5d9c745762cc4 100644 (file)
@@ -9975,6 +9975,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
     case VECTOR_TYPE:
     case INTEGER_TYPE:
     case BOOLEAN_TYPE:
+    case ENUMERAL_TYPE:
     case VOID_TYPE:
       if (TREE_CODE (arg) != TREE_CODE (parm))
        return 1;
@@ -10136,10 +10137,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
          else
            return 0;
        }
-      else
-       sorry ("use of `%s' in template type unification",
-              tree_code_name [(int) TREE_CODE (parm)]);
-
+      gcc_unreachable ();
       return 1;
     }
 }
index 2fa43121cfc5929e1734508e7bbbfa478222cd9a..f81a893348c6433ed1f5a3b27267eed1a78c6bd4 100644 (file)
@@ -1,3 +1,11 @@
+2004-09-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/16716
+       * g++.dg/parse/crash17.C: New test.
+       
+       PR c++/17327
+       * g++.dg/template/enum3.C: New test.
+
 2004-09-13  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * lib/gcc-defs.exp: Load wrapper.exp.
diff --git a/gcc/testsuite/g++.dg/parse/crash17.C b/gcc/testsuite/g++.dg/parse/crash17.C
new file mode 100644 (file)
index 0000000..bdc6639
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/16716
+
+template <typename> class allocator; 
+template<typename T> class vector { 
+  // With the dg-error on the next line, we are really just trying to
+  // check that the message is not an ICE message.
+  typedef typename allocator<T> allocator_type; // { dg-error "expected|forbids" }
+}; 
diff --git a/gcc/testsuite/g++.dg/template/enum3.C b/gcc/testsuite/g++.dg/template/enum3.C
new file mode 100644 (file)
index 0000000..b248d78
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/17327
+
+enum E { E0, E1 };
+template <class T,class U> class A {};
+template <class T> void f(A<E,T>) {}
+// We used to issue a "sorry" message.  By using an explicit error
+// message below, we make sure that we will not match "sorry".
+template void f(A<int,E>); // { dg-error "template-id" }