re PR c++/47974 (ICE: tree check: expected tree_vec, have error_mark in tsubst_templa...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 3 Mar 2011 17:07:28 +0000 (17:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 3 Mar 2011 17:07:28 +0000 (17:07 +0000)
/cp
2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/47974
* pt.c (tsubst_template_args): Check argument t for error_mark_node.

/testsuite
2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/47974
* g++.dg/template/crash106.C: New.

From-SVN: r170658

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

index ef766fbff3dfb1a2924bc8149c2b286b7b99dcc1..747457a193787de436dabcd09efe8126551ae978 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/47974
+       * pt.c (tsubst_template_args): Check argument t for error_mark_node.
+
 2011-03-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/47950
index 60b26996c47cb95f79b48a1a785f432d51e76e89..c52bb74eba80183b906e8497b7da6616b9d031ff 100644 (file)
@@ -8966,9 +8966,14 @@ static tree
 tsubst_template_args (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 {
   tree orig_t = t;
-  int len = TREE_VEC_LENGTH (t);
-  int need_new = 0, i, expanded_len_adjust = 0, out;
-  tree *elts = XALLOCAVEC (tree, len);
+  int len, need_new = 0, i, expanded_len_adjust = 0, out;
+  tree *elts;
+
+  if (t == error_mark_node)
+    return error_mark_node;
+
+  len = TREE_VEC_LENGTH (t);
+  elts = XALLOCAVEC (tree, len);
 
   for (i = 0; i < len; i++)
     {
index 3f7a372fa0a610039d39cb7f4ffe2b82808e35d7..69b7569c61542ca4da8634c6c44f901b6ec1a681 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/47974
+       * g++.dg/template/crash106.C: New.
+
 2011-03-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/47963
diff --git a/gcc/testsuite/g++.dg/template/crash106.C b/gcc/testsuite/g++.dg/template/crash106.C
new file mode 100644 (file)
index 0000000..c2d117e
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/47974
+
+typedef double T;
+
+struct A
+{
+  template<T> void foo(); // { dg-error "type" }
+};
+
+template<T N = 0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type|declared" }
+
+B<> b; // { dg-error "type|declaration" }