From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id BCDD03857022; Wed, 26 Apr 2023 21:16:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCDD03857022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682543796; bh=BQ70/QqbyhzJnW9kkbBHzJPHI4IgG8I24nvHTuhFsNg=; h=From:To:Subject:Date:From; b=VvYZet3/CFOuZTwQgnXelovzTIL6LljVGGVNt3onJ9U+bl21x7xBb/xoPOT9gyZO3 O7FnVbkjpLZ4amTQ0LXvpLYgEcybxd2bxEYoi6EWNTpgMuuDgSFN4T6Q6CyOYASCO2 6GPt8kfnRObvSQxfdXW7L/BObeckQegF/YWAddDE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-278] c++: local class in nested generic lambda [PR109241] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 1e27e7e0985e055b3d4ec92e93976b709fdbe425 X-Git-Newrev: d60cbbfaa9a3ad3bd1f613be95add939c16fc9a1 Message-Id: <20230426211636.BCDD03857022@sourceware.org> Date: Wed, 26 Apr 2023 21:16:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d60cbbfaa9a3ad3bd1f613be95add939c16fc9a1 commit r14-278-gd60cbbfaa9a3ad3bd1f613be95add939c16fc9a1 Author: Jason Merrill Date: Wed Mar 22 16:11:47 2023 -0400 c++: local class in nested generic lambda [PR109241] The earlier fix for PR109241 avoided the crash by handling a type with no TREE_BINFO. But we want to move toward doing the partial substitution of classes in generic lambdas, so let's take a step in that direction. PR c++/109241 gcc/cp/ChangeLog: * pt.cc (instantiate_class_template): Do partially instantiate. (tsubst_expr): Do call complete_type for partial instantiations. Diff: --- gcc/cp/pt.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index e1c272b9817..93a055c66a1 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12086,7 +12086,8 @@ instantiate_class_template (tree type) return error_mark_node; if (COMPLETE_OR_OPEN_TYPE_P (type) - || uses_template_parms (type)) + || (uses_template_parms (type) + && !TYPE_FUNCTION_SCOPE_P (type))) return type; /* Figure out which template is being instantiated. */ @@ -19356,10 +19357,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) case TAG_DEFN: tmp = tsubst (TREE_TYPE (t), args, complain, NULL_TREE); - if (dependent_type_p (tmp)) - /* This is a partial instantiation, try again when full. */ - add_stmt (build_min (TAG_DEFN, tmp)); - else if (CLASS_TYPE_P (tmp)) + if (CLASS_TYPE_P (tmp)) { /* Local classes are not independent templates; they are instantiated along with their containing function. And this @@ -19368,6 +19366,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) /* Closures are handled by the LAMBDA_EXPR. */ gcc_assert (!LAMBDA_TYPE_P (TREE_TYPE (t))); complete_type (tmp); + if (dependent_type_p (tmp)) + { + /* This is a partial instantiation, try again when full. */ + add_stmt (build_min (TAG_DEFN, tmp)); + break; + } tree save_ccp = current_class_ptr; tree save_ccr = current_class_ref; for (tree fld = TYPE_FIELDS (tmp); fld; fld = DECL_CHAIN (fld))