From: Jason Merrill Date: Wed, 26 Feb 2020 18:03:23 +0000 (-0500) Subject: c++: Fix decltype of empty pack expansion of parm. X-Git-Tag: releases/gcc-9.3.0~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a8996b0a7b238180f4a10b19b1e90b33e5b2df0;p=thirdparty%2Fgcc.git 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. gcc/cp/ChangeLog 2020-02-26 Jason Merrill PR c++/93140 * pt.c (tsubst_decl) [PARM_DECL]: Check cp_unevaluated_operand in handling of TREE_CHAIN for empty pack. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca4bc4cc1b50..8c4d662d7ec9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-02-26 Jason Merrill + + 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 PR c++/92852 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c7245efa2b26..c7ca7e419ea0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 000000000000..4300c781400c --- /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 +void foo (R... r, decltype (bar (r...)) x = 0) {} + +int +main () +{ + foo (3); +}