Patchwork [committed] Fix ICE in strip_typedefs (PR c++/56543)

login
register
mail settings
Submitter Jakub Jelinek
Date March 6, 2013, 3:25 p.m.
Message ID <20130306152525.GT12913@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/225530/
State New
Headers show

Comments

Jakub Jelinek - March 6, 2013, 3:25 p.m.
Hi!

If the second argument to TEMPLATE_ID_EXPR is NULL, there are no
explicit arguments, but we can't call copy_node (NULL).

Fixed thusly, acked by Jason in the PR, bootstrapped/regtested on
x86_64-linux and i686-linux, committed to trunk.

2013-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/56543
	* tree.c (strip_typedefs): Don't copy args if they are NULL.

	* g++.dg/template/typename20.C: New test.


	Jakub

Patch

--- gcc/cp/tree.c.jj	2013-02-24 19:44:07.000000000 +0100
+++ gcc/cp/tree.c	2013-03-06 13:49:38.182189955 +0100
@@ -1222,7 +1222,8 @@  strip_typedefs (tree t)
     case TYPENAME_TYPE:
       {
 	tree fullname = TYPENAME_TYPE_FULLNAME (t);
-	if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
+	if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR
+	    && TREE_OPERAND (fullname, 1))
 	  {
 	    tree args = TREE_OPERAND (fullname, 1);
 	    tree new_args = copy_node (args);
--- gcc/testsuite/g++.dg/template/typename20.C.jj	2013-03-06 14:05:42.381512570 +0100
+++ gcc/testsuite/g++.dg/template/typename20.C	2013-03-06 14:05:29.000000000 +0100
@@ -0,0 +1,11 @@ 
+// PR c++/56543
+
+template <typename>
+struct S;
+
+template <typename T>
+struct U
+{
+  typedef typename S <T>::template V <> W;
+  S <W> x;
+};