public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-52] c++: tidy auto deduction
Date: Fri, 29 Apr 2022 19:12:16 +0000 (GMT)	[thread overview]
Message-ID: <20220429191216.393053858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:8189838d823ea65e560c573d38a65edc12f5c2e3

commit r13-52-g8189838d823ea65e560c573d38a65edc12f5c2e3
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Apr 29 14:21:47 2022 -0400

    c++: tidy auto deduction
    
    In r185768 I added the !FUNCTION_DECL check, but we might as well just check
    for variable; nothing else should take this path, and asserting as much
    doesn't regress anything.
    
    gcc/cp/ChangeLog:
    
            * decl.cc (cp_finish_decl): Only consider auto for vars.

Diff:
---
 gcc/cp/decl.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 45206c236c1..16565bf0a0e 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8077,7 +8077,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
       && (DECL_INITIAL (decl) || init))
     DECL_INITIALIZED_IN_CLASS_P (decl) = 1;
 
-  if (TREE_CODE (decl) != FUNCTION_DECL
+  if (VAR_P (decl)
       && (auto_node = type_uses_auto (type)))
     {
       tree d_init;
@@ -8105,11 +8105,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	  d_init = resolve_nondeduced_context (d_init, tf_warning_or_error);
 	}
       enum auto_deduction_context adc = adc_variable_type;
-      if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl))
+      if (DECL_DECOMPOSITION_P (decl))
 	adc = adc_decomp_type;
       tree outer_targs = NULL_TREE;
       if (PLACEHOLDER_TYPE_CONSTRAINTS_INFO (auto_node)
-	  && VAR_P (decl)
 	  && DECL_LANG_SPECIFIC (decl)
 	  && DECL_TEMPLATE_INFO (decl)
 	  && !DECL_FUNCTION_SCOPE_P (decl))


                 reply	other threads:[~2022-04-29 19:12 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=20220429191216.393053858D28@sourceware.org \
    --to=jason@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: link
Be 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).