]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix decltype of empty pack expansion of parm.
authorJason Merrill <jason@redhat.com>
Wed, 26 Feb 2020 18:03:23 +0000 (13:03 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 26 Feb 2020 19:09:03 +0000 (14:09 -0500)
In unevaluated context, we only substitute a single PARM_DECL, not the
entire chain, but the handling of an empty pack expansion was missing that
check.

gcc/cp/ChangeLog
2020-02-26  Jason Merrill  <jason@redhat.com>

PR c++/93140
* pt.c (tsubst_decl) [PARM_DECL]: Check cp_unevaluated_operand in
handling of TREE_CHAIN for empty pack.

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

index ca4bc4cc1b50bf7743bde8aeec7f2d0e9aea1ce6..8c4d662d7ec959b1791685909cc439526f617d37 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/93140
+       * pt.c (tsubst_decl) [PARM_DECL]: Check cp_unevaluated_operand in
+       handling of TREE_CHAIN for empty pack.
+
 2020-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/92852
index c7245efa2b2680f4213dffc66b00bec156ab2939..c7ca7e419ea074d0e8c7aff2ed2487ead5d0a438 100644 (file)
@@ -13495,7 +13495,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 
                 /* Zero-length parameter packs are boring. Just substitute
                    into the chain.  */
-                if (len == 0)
+               if (len == 0 && !cp_unevaluated_operand)
                   RETURN (tsubst (TREE_CHAIN (t), args, complain,
                                  TREE_CHAIN (t)));
               }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C
new file mode 100644 (file)
index 0000000..4300c78
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/93140
+// { dg-do compile { target c++11 } }
+
+int
+bar ()
+{
+  return 42;
+}
+
+template <typename... R>
+void foo (R... r, decltype (bar (r...)) x = 0) {}
+
+int
+main ()
+{
+  foo (3);
+}