From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id CA4C93858402 for ; Thu, 18 Nov 2021 03:24:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CA4C93858402 Received: by mail-lf1-x132.google.com with SMTP id n12so18856167lfe.1 for ; Wed, 17 Nov 2021 19:24:10 -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=Ezqq+JkhLfJJb6wubeEsTn1JcYAlETTT9sRBHC4PdKQ=; b=KZpdKzAWZUbETJ5jCObQbqalpMhVp/gHtt+jz2mxzZD3l+oPn48YuBskNC/Dec7qxg hUPqV2QOdABZmAsFL3ubqpjcC1z/tqhzBwppF4yGPRYAw+Pt94LOSW2fZLm/BeTIp6c5 bLfWgScymLt5MRxzMYW45RmTFieMaeJR7tZZ/tFz9jG1CF7c9uxDdaaDGPrf7oK54ait BZ6pYnHcP5L+We92S5c9IRRgoJAMlNGZhD/FnU+OpGMxp7cgMdtsdl6yS0q7eVLy66z8 emR9KMbJIEA6cClymQsPD8tJWrNsQYPt2AHG0vk1sNS8hN1PPTcDp1DZJLlex78k5+4r IpqQ== X-Gm-Message-State: AOAM532A59QwCNaZrcZPelZ93mt+Mu2EJ954Kcw6BmCexkfLUBCfc9PB kX8FC//RYwdvwwDUvdhkACXOHlPRuo0w7NlHEmI= X-Google-Smtp-Source: ABdhPJxfnn3ZwWnZqS9w5mwKJOXVhoGuGcZA2EdsGx+sky5qQvG08C5UYlP1i+pJzgNruQ9vT7RPByiFOM37sLif6qA= X-Received: by 2002:a2e:8693:: with SMTP id l19mr13679694lji.452.1637205849418; Wed, 17 Nov 2021 19:24:09 -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:23:58 -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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, 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:24:12 -0000 V2 Patch https://gcc.gnu.org/bugzilla/attachment.cgi?id=51828 On Wed, Nov 17, 2021 at 10:06 PM will wray wrote: > > 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