From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 63D983853571 for ; Sat, 1 Oct 2022 04:15:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 63D983853571 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664597707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5YY+1mcCntb7vDmYBHilJUIhr1qVf4RZX7SL8sOJz+Y=; b=K4hCh0cTPpBDQ3mgYTA+8ehhZoHsfsoO2lKy7B2Cphv08JQDRYRZqtTi1LrkheeFqQKOam QFjjtPLCt9qZKZdMuu7ICKOTb7+bjvoo7C6IJKYUnNg73it5gy/mgb9CezyyH+aD7nqSAf oxYrrjA8IzxjDUQBay4mMAJIi2UTY0s= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-647-XbfwkwmQNxah2Rrt-UW2WA-1; Sat, 01 Oct 2022 00:15:05 -0400 X-MC-Unique: XbfwkwmQNxah2Rrt-UW2WA-1 Received: by mail-qv1-f70.google.com with SMTP id t19-20020a056214119300b004b03f58b1abso2341531qvv.17 for ; Fri, 30 Sep 2022 21:15:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=5YY+1mcCntb7vDmYBHilJUIhr1qVf4RZX7SL8sOJz+Y=; b=Fn+rCYuO2wac5RJnXg+4ie1jCx0+ex26lz0tG2gTOd2Kpj6Wr5kHAVvjxp3ZH+D4Tp RpCkWn5HExhrnrX9H+Oj0PZomKrtxFrvP39JdIQGxoONjkLcx7u4NqtDgnHHsyXgskTT JNmDIXyQXv7EG18V5oXVgbGP97721/RTmSIBxOJjs73cBlkOjGTodHXpQhXNVssoF8yF EcsCDcvsr54OPuSyAwU+dCD19xLHBwaOIMwoZtA5IyZHUxarS31Zw6LRm3gmrbCxrpG+ UwHqSRIR1HAqltAj11mwqU9wyV71Sel3/oXjRtOWUa2ydpziIfz/xin58m0hTxCk9vDq bijw== X-Gm-Message-State: ACrzQf028C6ej3xqyTJ6/MZ1bv5l4lF4R/VvWr1RwXjyuUyaRIIHkaBd xSrFpn6DHkDe1n0YbMNz3jO4WsCsd9qhzkSXxDh3MvGAKL42GQJp+BgU6tAPRTCL0EWuzj0oKcg rSu43WlVHk7UnT0/+fva8BewT3VybKAuP7HTwkxT3N8shQ6f8vnImgf/x7I91ecafZg== X-Received: by 2002:a0c:b3db:0:b0:4ad:8dff:399b with SMTP id b27-20020a0cb3db000000b004ad8dff399bmr9299245qvf.4.1664597705060; Fri, 30 Sep 2022 21:15:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nRJvU6K5OPaNYL8EoE6Knii7is8FRlvCQZ8aMhJW9Hv5v4J2LoeSP7UrvVJ0r3lTQrKQjHQ== X-Received: by 2002:a0c:b3db:0:b0:4ad:8dff:399b with SMTP id b27-20020a0cb3db000000b004ad8dff399bmr9299235qvf.4.1664597704755; Fri, 30 Sep 2022 21:15:04 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id 16-20020ac84e90000000b0035d4b13363fsm3862410qtp.48.2022.09.30.21.15.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 21:15:04 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: loop through array CONSTRUCTOR Date: Sat, 1 Oct 2022 00:15:02 -0400 Message-Id: <20221001041502.2211988-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-pc-linux-gnu, applying to trunk. -- >8 -- I noticed that we were ignoring all the special rules for when to use a simple INIT_EXPR for array initialization from a CONSTRUCTOR, because split_nonconstant_init_1 was also passing 1 to the from_array parameter. Arguably that's the real bug, but I think we can be flexible. The test that I noticed this with no longer fails without it. gcc/cp/ChangeLog: * init.cc (build_vec_init): Clear from_array for CONSTRUCTOR initializer. --- gcc/cp/init.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index a85c3032130..bf46578c08b 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4394,6 +4394,10 @@ build_vec_init (tree base, tree maxindex, tree init, } } + /* from_array doesn't apply to initialization from CONSTRUCTOR. */ + if (init && TREE_CODE (init) == CONSTRUCTOR) + from_array = 0; + /* If we have a braced-init-list or string constant, make sure that the array is big enough for all the initializers. */ bool length_check = (init @@ -4493,7 +4497,7 @@ build_vec_init (tree base, tree maxindex, tree init, /* If initializing one array from another, initialize element by element. We rely upon the below calls to do the argument checking. Evaluate the initializer before entering the try block. */ - if (from_array && init && TREE_CODE (init) != CONSTRUCTOR) + if (from_array) { if (lvalue_kind (init) & clk_rvalueref) xvalue = true; base-commit: aa360fbf68b11e54017e8fa5b1bdb87ce7c19188 prerequisite-patch-id: 69446a92a4457ed77776068289cdcdb5a4c74b4d -- 2.31.1