]> gcc.gnu.org Git - gcc.git/commitdiff
c++: tidy auto deduction
authorJason Merrill <jason@redhat.com>
Fri, 29 Apr 2022 18:21:47 +0000 (14:21 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 29 Apr 2022 19:12:07 +0000 (15:12 -0400)
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.

gcc/cp/decl.cc

index 45206c236c1cabed940f22d9c3daa71d1df05f83..16565bf0a0e7e7eb70fef048f8a15efad4f6d395 100644 (file)
@@ -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))
This page took 0.081467 seconds and 5 git commands to generate.