[gcc/devel/ranger] c++: Fix decltype of empty pack expansion of parm.

Aldy Hernandez aldyh@gcc.gnu.org
Wed Jun 17 18:38:34 GMT 2020


https://gcc.gnu.org/g:f6bef09771cf93e695cf719fb43db8c43e31acf5

commit f6bef09771cf93e695cf719fb43db8c43e31acf5
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 5 17:59:28 2020 -0500

    c++: Fix decltype of empty pack expansion of parm.
    
    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.
    
            PR c++/93140
            * pt.c (tsubst_decl) [PARM_DECL]: Check cp_unevaluated_operand in
            handling of TREE_CHAIN for empty pack.

Diff:
---
 gcc/cp/ChangeLog                            |  6 ++++++
 gcc/cp/pt.c                                 |  2 +-
 gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C | 17 +++++++++++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 12bbecfdda1..6a7ba564d12 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-05  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-05  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/93557
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 40ff3c3a089..01bade85cdf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14076,7 +14076,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
index 00000000000..4300c781400
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C
@@ -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);
+}


More information about the Gcc-cvs mailing list