diff mbox

C++ PATCH for c++/56059 (ICE on error with decltype)

Message ID 50FDEAEE.4020500@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 22, 2013, 1:27 a.m. UTC
Here when I rebuilt the TREE_VEC of template arguments, I forgot to 
preserve the count of non-default args.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
diff mbox

Patch

commit ac41deca2b7fcbda67a0e99f112e116589e56ad8
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jan 21 15:46:57 2013 -0500

    	PR c++/56059
    	* tree.c (strip_typedefs_expr) [TREE_VEC]: Preserve non-default
    	template args count.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 2b108c1..d1f14fc 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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
index 0000000..29ce815
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype48.C
@@ -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;
+}