From: Jason Merrill Date: Tue, 17 Jul 2018 15:39:46 +0000 (-0400) Subject: PR c++/86480 - nested variadic lambda and constexpr if. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd00049ae93c8dd0feba1702be3f2c2ebeb92189;p=gcc.git PR c++/86480 - nested variadic lambda and constexpr if. * pt.c (find_parameter_packs_r) [IF_STMT]: Don't walk into IF_STMT_EXTRA_ARGS. * tree.c (cp_walk_subtrees) [DECLTYPE_TYPE]: Set cp_unevaluated_operand. [ALIGNOF_EXPR] [SIZEOF_EXPR] [NOEXCEPT_EXPR]: Likewise. From-SVN: r262825 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6c1384a074f..f6f43985125 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2018-07-17 Jason Merrill + + PR c++/86480 - nested variadic lambda and constexpr if. + * pt.c (find_parameter_packs_r) [IF_STMT]: Don't walk into + IF_STMT_EXTRA_ARGS. + * tree.c (cp_walk_subtrees) [DECLTYPE_TYPE]: Set + cp_unevaluated_operand. + [ALIGNOF_EXPR] [SIZEOF_EXPR] [NOEXCEPT_EXPR]: Likewise. + 2018-07-16 Paolo Carlini * class.c (resolve_address_of_overloaded_function): Don't emit an diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b49dce08206..27805040ddb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3865,6 +3865,17 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) return NULL_TREE; } + case IF_STMT: + cp_walk_tree (&IF_COND (t), &find_parameter_packs_r, + ppd, ppd->visited); + cp_walk_tree (&THEN_CLAUSE (t), &find_parameter_packs_r, + ppd, ppd->visited); + cp_walk_tree (&ELSE_CLAUSE (t), &find_parameter_packs_r, + ppd, ppd->visited); + /* Don't walk into IF_STMT_EXTRA_ARGS. */ + *walk_subtrees = 0; + return NULL_TREE; + default: return NULL_TREE; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index b1333f55e39..7e2a77bf67b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4865,7 +4865,19 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, break; case DECLTYPE_TYPE: - WALK_SUBTREE (DECLTYPE_TYPE_EXPR (*tp)); + ++cp_unevaluated_operand; + /* We can't use WALK_SUBTREE here because of the goto. */ + result = cp_walk_tree (&DECLTYPE_TYPE_EXPR (*tp), func, data, pset); + --cp_unevaluated_operand; + *walk_subtrees_p = 0; + break; + + case ALIGNOF_EXPR: + case SIZEOF_EXPR: + case NOEXCEPT_EXPR: + ++cp_unevaluated_operand; + result = cp_walk_tree (&TREE_OPERAND (*tp, 0), func, data, pset); + --cp_unevaluated_operand; *walk_subtrees_p = 0; break; diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if24.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if24.C new file mode 100644 index 00000000000..cbdb38d95c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if24.C @@ -0,0 +1,21 @@ +// PR c++/86480 +// { dg-additional-options -std=c++17 } + +template constexpr bool val = true; + +template +void f() +{ + [](auto... p) + { + []{ + if constexpr (val) { return true; } + return false; + }(); + }(42); +} + +int main() +{ + f(); +}