C++ PATCH for c++/45698 (crash with variadics)

Message ID 4DDD5C6A.4030405@redhat.com
State New
Headers show

Commit Message

Jason Merrill May 25, 2011, 7:45 p.m.
45698 was actually fixed in 4.5.0, but before I closed it I checked to 
see how the testcase was doing with the current compiler, and found that 
it was crashing again.  This turned out to be because of Nathan's recent 
tree-slimming work; ARGUMENT_PACK_SELECT doesn't have TREE_TYPE, so we 
crash when we try to look at it in value_dependent_expression_p.  But we 
shouldn't be treating it as an expression in the first place, since it 
could be either a type or value argument.

Fixed by looking through ARGUMENT_PACK_SELECT before we decide what sort 
of template argument we're dealing with.

While looking at this, I also noticed that print_node expects everything 
to have TREE_TYPE, which is no longer correct.  And I made print_node 
more useful for ARGUMENT_PACK_SELECT.

Tested x86_64-pc-linux-gnu, applying to trunk.


commit 46cccd60afea40407a278f6d937373e0121c24ee
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 25 13:32:05 2011 -0400

    	* print-tree.c (print_node): Only look at TREE_TYPE if TS_TYPED.
    	* cp/ptree.c (cxx_print_xnode): Handle ARGUMENT_PACK_SELECT.

diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index a4c3ed5..5c9626e 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -221,6 +221,12 @@  cxx_print_xnode (FILE *file, tree node, int indent)
 	  fprintf (file, "pending_template");
+      print_node (file, "pack", ARGUMENT_PACK_SELECT_FROM_PACK (node),
+		  indent+4);
+      indent_to (file, indent + 3);
+      fprintf (file, "index %d", ARGUMENT_PACK_SELECT_INDEX (node));
+      break;
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index 3b5edeb..58c9613 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -321,7 +321,7 @@  print_node (FILE *file, const char *prefix, tree node, int indent)
       if (indent <= 4)
 	print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
-  else
+  else if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
       print_node (file, "type", TREE_TYPE (node), indent + 4);
       if (TREE_TYPE (node))