]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42634 (ICE with -g -O2 -std=c++0x in copy_fn_p, at cp/decl.c:9973)
authorDodji Seketeli <dodji@redhat.com>
Mon, 18 Jan 2010 21:18:49 +0000 (21:18 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Mon, 18 Jan 2010 21:18:49 +0000 (22:18 +0100)
Fix PR c++/42634

gcc/cp/ChangeLog:
    PR c++/42634
    * error.c (dump_template_parms): Use innermost template
    arguments before calling count_non_default_template_args.
    (count_non_default_template_args): We are being called with
    template innermost arguments now. There is no need to ensure
    that again.

gcc/testsuite/ChangeLog:
    PR c++/42634
    * g++.dg/template/error45.C: New test.

From-SVN: r156022

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

index ccb2afec9e4573aae5e65522fd99183ce7e800bc..5325a6c9e14231abbe3b4caec1563ce18e111c69 100644 (file)
@@ -1,3 +1,12 @@
+2010-01-18  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42634
+       * error.c (dump_template_parms): Use innermost template
+       arguments before calling count_non_default_template_args.
+       (count_non_default_template_args): We are being called with
+       template innermost arguments now. There is no need to ensure
+       that again.
+
 2010-01-18  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/42766
index e0e5ae52ceb73f90b739655b92a4add6acd3141e..54e96810f9bc696ce43e818a0e75893bbe021c24 100644 (file)
@@ -165,8 +165,7 @@ dump_template_argument (tree arg, int flags)
 static int
 count_non_default_template_args (tree args, tree params, int flags)
 {
-  tree inner_args = INNERMOST_TEMPLATE_ARGS (args);
-  int n = TREE_VEC_LENGTH (inner_args);
+  int n = TREE_VEC_LENGTH (args);
   int last;
 
   if (params == NULL_TREE
@@ -195,7 +194,7 @@ count_non_default_template_args (tree args, tree params, int flags)
                                       NULL_TREE, false, true);
          --processing_template_decl;
        }
-      if (!cp_tree_equal (TREE_VEC_ELT (inner_args, last), def))
+      if (!cp_tree_equal (TREE_VEC_ELT (args, last), def))
         break;
     }
 
@@ -1492,9 +1491,9 @@ dump_template_parms (tree info, int primary, int flags)
                     ? DECL_INNERMOST_TEMPLATE_PARMS (TI_TEMPLATE (info))
                     : NULL_TREE);
 
+      args = INNERMOST_TEMPLATE_ARGS (args);
       len = count_non_default_template_args (args, params, flags);
 
-      args = INNERMOST_TEMPLATE_ARGS (args);
       for (ix = 0; ix != len; ix++)
        {
          tree arg = TREE_VEC_ELT (args, ix);
index 11a7540f5719c98187b917fa0850063cb334ad1c..5383251540536c324dd550efd3d63ac5a5f57eba 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-18  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42634
+       * g++.dg/template/error45.C: New test.
+
 2010-01-18  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/42766
diff --git a/gcc/testsuite/g++.dg/template/error45.C b/gcc/testsuite/g++.dg/template/error45.C
new file mode 100644 (file)
index 0000000..f5332ee
--- /dev/null
@@ -0,0 +1,34 @@
+// Origin PR c++/42634
+// { dg-options "-g -std=gnu++0x" }
+// { dg-do compile }
+
+template<typename T> T declval();
+
+template<typename T, typename... Args> struct is_constructible {
+    template<typename T1, typename... Args1> static decltype(T1(declval<Args1>()...), char()) test();
+    static const bool value = sizeof(test<T, Args...>()) == 1;
+};
+template<bool> struct enable_if {
+        typedef void type;
+};
+template<class T1, class T2> struct pair {
+    template<class U2,
+             class = typename enable_if<is_constructible<T2,U2&&>::value>::type
+             >
+    pair(const T1&, U2&&) { }
+};
+struct string {
+  string() : p(0) {}
+  char* p;
+};
+
+struct Foo {
+  string s;
+  int i;
+};
+
+void f()
+{
+  pair<int, Foo>(1, Foo());
+}
+