re PR c++/56059 (SIGSEGV on invalid C++11 code)
authorJason Merrill <jason@redhat.com>
Tue, 22 Jan 2013 01:27:19 +0000 (20:27 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 22 Jan 2013 01:27:19 +0000 (20:27 -0500)
PR c++/56059
* tree.c (strip_typedefs_expr) [TREE_VEC]: Preserve non-default
template args count.

From-SVN: r195355

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/decltype48.C [new file with mode: 0644]

index 6370f7f..162420b 100644 (file)
@@ -1,3 +1,9 @@
+2013-01-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56059
+       * tree.c (strip_typedefs_expr) [TREE_VEC]: Preserve non-default
+       template args count.
+
 2013-01-18  Jason Merrill  <jason@redhat.com>
 
        PR target/54908
index 2b108c1..d1f14fc 100644 (file)
@@ -1351,6 +1351,8 @@ strip_typedefs_expr (tree t)
            r = copy_node (t);
            for (i = 0; i < n; ++i)
              TREE_VEC_ELT (r, i) = (*vec)[i];
+           SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
+             (r, GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (t));
          }
        else
          r = t;
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype48.C b/gcc/testsuite/g++.dg/cpp0x/decltype48.C
new file mode 100644 (file)
index 0000000..29ce815
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/56059
+// { dg-options -std=c++11 }
+
+typedef int Int;
+template<typename T> struct baz { };
+template<typename T> T bar();
+
+template<typename T, typename ... U>
+baz<decltype(bar<Int>(bar<U>() ...))> // { dg-error "no match" }
+foo();
+
+int main()
+{
+  foo<int, int>();             // { dg-error "no match" }
+  return 0;
+}