public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-4681] c++: A couple of template instantiation cleanups Date: Tue, 3 Nov 2020 16:49:45 +0000 (GMT) [thread overview] Message-ID: <20201103164945.399AC3987017@sourceware.org> (raw) https://gcc.gnu.org/g:1c8b8efa5becb70e04216a60021b835387ffea4e commit r11-4681-g1c8b8efa5becb70e04216a60021b835387ffea4e Author: Nathan Sidwell <nathan@acm.org> Date: Tue Nov 3 08:39:47 2020 -0800 c++: A couple of template instantiation cleanups I noticed that we were handling lambda extra scope during template instantiation in a different order to how we handle the non-template case. Reordered that for consistency. Also some more RAII during template instantiation. gcc/cp/ * pt.c (tsubst_lambda_expr): Reorder extra-scope handling to match the non-template case. (instantiate_body): Move a couple of declarations to their initializers. Diff: --- gcc/cp/pt.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c3492f66c9a..f1c8c0913ec 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19081,15 +19081,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) LAMBDA_EXPR_MUTABLE_P (r) = LAMBDA_EXPR_MUTABLE_P (t); LAMBDA_EXPR_INSTANTIATED (r) = true; - if (LAMBDA_EXPR_EXTRA_SCOPE (t) == NULL_TREE) - /* A lambda in a default argument outside a class gets no - LAMBDA_EXPR_EXTRA_SCOPE, as specified by the ABI. But - tsubst_default_argument calls start_lambda_scope, so we need to - specifically ignore it here, and use the global scope. */ - record_null_lambda_scope (r); - else - record_lambda_scope (r); - gcc_assert (LAMBDA_EXPR_THIS_CAPTURE (t) == NULL_TREE && LAMBDA_EXPR_PENDING_PROXIES (t) == NULL); @@ -19168,6 +19159,15 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (type == error_mark_node) return error_mark_node; + if (LAMBDA_EXPR_EXTRA_SCOPE (t) == NULL_TREE) + /* A lambda in a default argument outside a class gets no + LAMBDA_EXPR_EXTRA_SCOPE, as specified by the ABI. But + tsubst_default_argument calls start_lambda_scope, so we need to + specifically ignore it here, and use the global scope. */ + record_null_lambda_scope (r); + else + record_lambda_scope (r); + /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */ determine_visibility (TYPE_NAME (type)); @@ -25571,9 +25571,6 @@ instantiate_body (tree pattern, tree args, tree d, bool nested_p) if (VAR_P (d)) { - tree init; - bool const_init = false; - /* Clear out DECL_RTL; whatever was there before may not be right since we've reset the type of the declaration. */ SET_DECL_RTL (d, NULL); @@ -25583,7 +25580,8 @@ instantiate_body (tree pattern, tree args, tree d, bool nested_p) regenerate_decl_from_template so we don't need to push/pop_access_scope again here. Pull it out so that cp_finish_decl can process it. */ - init = DECL_INITIAL (d); + bool const_init = false; + tree init = DECL_INITIAL (d); DECL_INITIAL (d) = NULL_TREE; DECL_INITIALIZED_P (d) = 0;
reply other threads:[~2020-11-03 16:49 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201103164945.399AC3987017@sourceware.org \ --to=nathan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).