From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 340E73858402 for ; Thu, 18 Nov 2021 03:06:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 340E73858402 Received: by mail-lf1-x12f.google.com with SMTP id l22so18346927lfg.7 for ; Wed, 17 Nov 2021 19:06:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CnhQRGWuDE4Q+2xoxHelvGmOTgKBLjAIZCNz2+0KyPg=; b=QevztreNZPhA/p7jnrgE/+psf/9hpVO/sbi3S0KgyldJzrVmOWvHDL1Yy4nwf/acpL umrS3WIBKCHeyVnlZz7FdtzODOFkytcTcGBKPB+UQpNXhnpLMOJck5GQYmxuTOZhhseN Mnlqkn+d4ElIgq/5d+8UxaqVTJ98hV4omqAgrHzGdRXYHIvCiq0FOSsvaK9nd8OgQHHl 4dD4fJ9v0pSIrMY1/YU01IzpVS1hqjhPjjBCFjBR0kemMkb4NYp6Ef8NI4m5x0MJvhVn kTfc3Z3wpi+H4C5rJf7WVg/O5+DDyrxQSbd6JWhuRYDNkxc+nB4MrfAhgIRF/nwwh8EE OmJg== X-Gm-Message-State: AOAM530SxLn/qSaR2Eqpdv8+zEvS8YcIdgZpqzgDpUWqwp18fGJom4lG UwI6058RFvIrmrB+NtgBn7jQj35goYkNkWlgVdY= X-Google-Smtp-Source: ABdhPJzn+ftqQsPbPyU890GYU/rrx4faMnH2kH0oLDQURHdh0V1kjiTRMeiH5ZCb9X8PXEPZl00hbq9TpDLEkZvl0ME= X-Received: by 2002:ac2:464f:: with SMTP id s15mr20249332lfo.590.1637204784753; Wed, 17 Nov 2021 19:06:24 -0800 (PST) MIME-Version: 1.0 References: <20211107001723.2528944-1-wjwray@gmail.com> In-Reply-To: From: will wray Date: Wed, 17 Nov 2021 22:06:13 -0500 Message-ID: Subject: Re: [PATCH] c++: designated init of char array by string constant [PR55227] To: Marek Polacek Cc: gcc-patches List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2021 03:06:28 -0000 Thanks for the review Marek; I'll post the updated patch in a follow-on message and on bugzilla. On Mon, Nov 15, 2021 at 8:03 PM Marek Polacek wrote: > I also noticed the C++ FE rejects > > struct A { char x[4]; }; > struct B { struct A a; }; > struct B b = { .a.x = "abc" }; > but the C FE accepts it. But that's for another time. Yes, the nested case is invalid for C++, valid for C. c.f. cppreference aggregate init. > > + reshape_iter stripd = {}; > > Since the previous variables spell it "stripped" maybe call it stripped_iter. I've left it as "stripd"; the top level reshape_iter is just "d", non-verbose, so "stripped_d" inappropriately over-verbose. > > @@ -6836,7 +6838,8 @@ reshape_init_r (tree type, reshape_iter *d, tree first_initializer_p, > > array types (one value per array element). */ > > if (TREE_CODE (stripped_str_init) == STRING_CST) > > { > > - if (has_designator_problem (d, complain)) > > So the logic here is that... Yes, you get the logic exactly... took me a few rounds to get it. > Nice to finally remove this, but let's keep this part of the comment. Agreed, and reinstated. > BRACE_ENCLOSED_INITIALIZER_P checks that it gets a CONSTRUCTOR so you > can remove the first check. Nice, thanks; missed that. > > +// { dg-do compile } > > +// { dg-options "-pedantic" } > > FWIW, if you remove the dg-options, -pedantic-errors will be used so you could > drop it and then use dg-error instead of dg-warning below but this is OK too. I'd copied that from another desigN.C test, now I've copied the simpler: +// { dg-options "" } and removed all of the noisy dg-warning tests > We should probably test more: > - nested structs > - anonymous unions > - test when the initializer is too long > - multidim arrays: Cut-n-paste'd your multidim array test, and added a couple more > Hope this is useful... Very useful, thanks again