]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/53498 (Compiler crashes during C++11 template magic compilation)
authorJason Merrill <jason@redhat.com>
Tue, 26 Jun 2012 03:42:34 +0000 (23:42 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 26 Jun 2012 03:42:34 +0000 (23:42 -0400)
PR c++/53498
PR c++/53305
* pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN
if cp_unevaluated_operand is set.
(tsubst_copy) [PARM_DECL]: Don't copy before tsubsting.

From-SVN: r188973

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

index 2d321b0005eb3aeeded3172c7cec3b7eeaf2c586..e80d3dc0e2e08a45070363d66ee93f4c0cae7a50 100644 (file)
@@ -1,5 +1,11 @@
 2012-06-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53498
+       PR c++/53305
+       * pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN
+       if cp_unevaluated_operand is set.
+       (tsubst_copy) [PARM_DECL]: Don't copy before tsubsting.
+
        PR c++/52988
        * typeck.c (decay_conversion): Don't discard side-effects from
        expressions of nullptr_t.
index ad7134b4d978570d9ecae50cdb782517bed9f2ce..7e1c46f77c364c1f1cb4408d3669ddbe93fde913 100644 (file)
@@ -10497,7 +10497,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
               DECL_CHAIN (prev_r) = r;
           }
 
-       if (DECL_CHAIN (t))
+       /* If cp_unevaluated_operand is set, we're just looking for a
+          single dummy parameter, so don't keep going.  */
+       if (DECL_CHAIN (t) && !cp_unevaluated_operand)
          DECL_CHAIN (r) = tsubst (DECL_CHAIN (t), args,
                                   complain, DECL_CHAIN (t));
 
@@ -12078,8 +12080,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
       if (r == NULL_TREE)
        {
-         tree c;
-
          /* We get here for a use of 'this' in an NSDMI.  */
          if (DECL_NAME (t) == this_identifier
              && at_function_scope_p ()
@@ -12090,12 +12090,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
             declaration (such as in a late-specified return type).  Just
             make a dummy decl, since it's only used for its type.  */
          gcc_assert (cp_unevaluated_operand != 0);
-         /* We copy T because want to tsubst the PARM_DECL only,
-            not the following PARM_DECLs that are chained to T.  */
-         c = copy_node (t);
-         r = tsubst_decl (c, args, complain);
-         if (r == NULL_TREE)
-           return error_mark_node;
+         r = tsubst_decl (t, args, complain);
          /* Give it the template pattern as its context; its true context
             hasn't been instantiated yet and this is good enough for
             mangling.  */
index b4f21e7493e1fdcc6e53a28500be6aba086da900..a85b990ee8de8d863ce51aa86ac9a7a37fed9e1a 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53498
+       PR c++/53305
+       * g++.dg/cpp0x/decltype38.C: New.
+       * g++.dg/cpp0x/variadic132.C: Remove dg-error.
+
 2012-06-25  Janis Johnson  <janisjo@codesourcery.com>
 
        * lib/target-supports-dg.exp (testname-for-summary): New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype38.C b/gcc/testsuite/g++.dg/cpp0x/decltype38.C
new file mode 100644 (file)
index 0000000..97ebb33
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/53498
+// { dg-do compile { target c++11 } }
+
+template<typename... Args>
+struct B
+{
+  template<typename U>
+  static
+  void b(const U& u, const Args&... args,
+        decltype(u.f(args...)) dummy)
+  {
+  }
+};
+
+int main() {
+  B<int> b;
+}
index f50c7a659f56e181de7886ff405ef41c56f4cbb6..1b9c28686843ae18cd60f957b2be99b1f9de362e 100644 (file)
@@ -9,11 +9,11 @@ struct funct
   int operator()(argTs...);
 };
 
-template<class...> class test;
+template<class...> struct test;
 
 template<template <class...> class tp,
         class... arg1Ts, class... arg2Ts>
-class test<tp<arg1Ts...>, tp<arg2Ts...>>
+struct test<tp<arg1Ts...>, tp<arg2Ts...>>
 {
   template<class func, class...arg3Ts>
     auto test2(func fun, arg1Ts... arg1s, arg3Ts... arg3s)
@@ -23,5 +23,5 @@ class test<tp<arg1Ts...>, tp<arg2Ts...>>
 int main()
 {
   test<tuple<>, tuple<char,int>> t2;
-  t2.test2(funct(), 'a', 2);  // { dg-error "no matching function" }
+  t2.test2(funct(), 'a', 2);
 }
This page took 0.14412 seconds and 5 git commands to generate.