Patchwork [C++] PR 46046

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 17, 2010, 11:41 p.m.
Message ID <4CBB89B1.8030000@oracle.com>
Download mbox | patch
Permalink /patch/68099/
State New
Headers show

Comments

Paolo Carlini - Oct. 17, 2010, 11:41 p.m.
Hi,

I have this small patch for an ICE on invalid, tested x86_64-linux.

Ok for mainline?

Thanks,
Paolo.

///////////////////////
/cp
2010-10-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46046
	* pt.c (add_to_template_args): Check extra_args for error_mark_node.
	(coerce_template_parms): Likewise for args.

/testsuite
2010-10-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46046
	* testsuite/g++.dg/template/crash104.C: New.
Jason Merrill - Oct. 19, 2010, 9:49 p.m.
Ok.

Jason

Patch

Index: testsuite/g++.dg/template/crash104.C
===================================================================
--- testsuite/g++.dg/template/crash104.C	(revision 0)
+++ testsuite/g++.dg/template/crash104.C	(revision 0)
@@ -0,0 +1,26 @@ 
+// PR c++/46046
+
+template <class T>
+    struct foo
+{
+    template <class U, class V = void>
+        struct type
+    {};
+
+    template <class V>
+        struct type<
+            typename T::template some_type<int>,
+            V
+        >
+    {};
+};
+
+template <class T>
+    class bar
+{};
+
+int main()
+{
+  typedef foo<bar<int> > cont;
+  cont::type<char> obj; // { dg-error "cannot be defined" }
+}
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 165602)
+++ cp/pt.c	(working copy)
@@ -490,7 +490,7 @@  add_to_template_args (tree args, tree extra_args)
   int i;
   int j;
 
-  if (args == NULL_TREE)
+  if (args == NULL_TREE || extra_args == error_mark_node)
     return extra_args;
 
   extra_depth = TMPL_ARGS_DEPTH (extra_args);
@@ -5970,6 +5970,9 @@  coerce_template_parms (tree parms,
      parameters.  */
   int variadic_p = 0;
 
+  if (args == error_mark_node)
+    return error_mark_node;
+
   nparms = TREE_VEC_LENGTH (parms);
 
   /* Determine if there are any parameter packs.  */