https://gcc.gnu.org/g:60335dec4d21b5956afc1e3f1d865fed0b3cfd39

commit r17-1661-g60335dec4d21b5956afc1e3f1d865fed0b3cfd39
Author: Marek Polacek <[email protected]>
Date:   Wed Jun 17 14:20:53 2026 -0400

    c++: simplify condition in check_initializer
    
    This condition has become unwieldy and hard to read.
    In <https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720712.html>
    I tried to factor it out into a separate function but it works to
    just drop the complicated inner disjunction.  I ran the testsuite
    checking if we exercise the case where the new and old conditions
    evaluate to different values and many tests triggered that.
    
    gcc/cp/ChangeLog:
    
            * decl.cc (check_initializer): Don't call
            build_aggr_init_full_exprs for {} of an aggregate.
    
    Reviewed-by: Jason Merrill <[email protected]>

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

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 23f23b39544d..50ebb38b55b8 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8587,15 +8587,9 @@ check_initializer (tree decl, tree init, int flags, 
vec<tree, va_gc> **cleanups)
 
       if (((type_build_ctor_call (type) || CLASS_TYPE_P (type))
           && !(flags & LOOKUP_ALREADY_DIGESTED)
-          && !(init && BRACE_ENCLOSED_INITIALIZER_P (init)
-               && CP_AGGREGATE_TYPE_P (type)
-               && (CLASS_TYPE_P (type)
-                   /* The call to build_aggr_init below could end up
-                      calling build_vec_init, which may break when we
-                      are processing a template.  */
-                   || processing_template_decl
-                   || !TYPE_NEEDS_CONSTRUCTING (type)
-                   || type_has_extended_temps (type))))
+          && !(init
+               && BRACE_ENCLOSED_INITIALIZER_P (init)
+               && CP_AGGREGATE_TYPE_P (type)))
          || (DECL_DECOMPOSITION_P (decl) && TREE_CODE (type) == ARRAY_TYPE))
        {
          init_code = build_aggr_init_full_exprs (decl, init, flags);

Reply via email to