diff options
author | Jason Merrill <jason@redhat.com> | 2019-02-27 16:54:25 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-02-27 16:54:25 -0500 |
commit | e6df04c105464436e700013e1f665ebf0f94c9f2 (patch) | |
tree | 13b41c71195608f85e18e625f3a53dd5ecb4a1ab /gcc/cp/pt.c | |
parent | 5b0a9c7cc1fa723369df61598cd3a8af4d21f5ff (diff) | |
download | gcc-e6df04c105464436e700013e1f665ebf0f94c9f2.zip gcc-e6df04c105464436e700013e1f665ebf0f94c9f2.tar.gz gcc-e6df04c105464436e700013e1f665ebf0f94c9f2.tar.bz2 |
PR c++/86969 - ICE with constexpr if and recursive generic lambdas.
Here, the problem was that extract_local_specs wasn't seeing that we use
'self' inside the lambda in the else of the inner constexpr if, because we
don't walk into lambda bodies and we didn't capture it in the lambda because
'self' is still dependent. Marek recently changed process_outer_var_ref to
do more implicit capture in templates; this example shows that we should
always capture non-packs, so that we can continue to not walk into lambda
bodies. We do walk into lambda bodies for pack expansions, so we can delay
deciding whether we're capturing a single element or the entire pack.
Immediately capturing a VLA means we need to create a dependent VLA capture
type, and not in the context of the lambda op(), since trying to look up the
instantiation of the op() while we're substituting into the capture list
would crash. So I force TYPE_CONTEXT and the binding level out to the
enclosing function before pushtag, avoid adding a TAG_DEFN, and instead
force the type to be complete in tsubst_lambda_expr.
* semantics.c (process_outer_var_ref): Do capture dependent vars.
* class.c (finish_struct): Only add TAG_DEFN if T is in
current_function_decl.
* lambda.c (vla_capture_type): Force the capture type out into the
lambda's enclosing function.
(add_capture): Pass in the lambda.
* pt.c (tsubst_lambda_expr): complete_type a VLA capture type.
From-SVN: r269265
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d678e27..673ea8e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17989,6 +17989,10 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (PACK_EXPANSION_P (ofield)) ofield = PACK_EXPANSION_PATTERN (ofield); tree field = tsubst_decl (ofield, args, complain); + if (DECL_VLA_CAPTURE_P (ofield)) + /* The type of a VLA capture might not have a TAG_DEFN in the enclosing + context, so complete it here. */ + complete_type (TREE_TYPE (field)); if (DECL_PACK_P (ofield) && !DECL_NORMAL_CAPTURE_P (ofield)) { |