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.133.124]) by sourceware.org (Postfix) with ESMTPS id 58AF4385780E for ; Thu, 28 Oct 2021 14:56:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58AF4385780E Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-2ksv9PDtNWKbmRX2P8Q81w-1; Thu, 28 Oct 2021 10:56:50 -0400 X-MC-Unique: 2ksv9PDtNWKbmRX2P8Q81w-1 Received: by mail-qt1-f197.google.com with SMTP id f7-20020a05622a104700b002a7bc1702d3so4509071qte.20 for ; Thu, 28 Oct 2021 07:56:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=uOW+EWGM91l03sZhMiE+I87lbAKkx+f0IFbliFy+TBk=; b=r6n6fROcZ7LCge0X5yoZRCXI8nGW5EKZvgyYrpGgtVv1bQZevQwWRmPlyzrb+YV65J SOK4prVo0t4vfPeibL/29EeKod+KDTsXqaYTD4lNNUaoJje237MxrhgGdjeD/E6jcQiv aYkWKgjE7Hqf+CUQ2S6hyAdOXsqtm/fbF+Opiv2mLz/Dk7zcB+iFW2NzhXQlDHkmUSX4 HNvfBbxo5LuVrGQiQ9JV3k7OpJE157exYcvJuNubdXS8m0merY+51LFhwbjlCfFiKZNV /wCKcsNhjW/tGelPOu0dQUCivJkmRtSrwNMJF5/MYkdXPEdP8XYpA7jf9+Twp6REUPgi Hbyw== X-Gm-Message-State: AOAM530pttSp+qb1muSkC2Fpm8/fdHGu19nPgYdQds/LyI1stGREKACG FrkGN7O5RRhFcnd/54FXWn6MaR3VNa1ydgf/MP0D2H748NTbCuHsiOJJnJuA3S8xcpubSEbpRM5 cWOUw2nbZhHT+drtP2w== X-Received: by 2002:a05:622a:18f:: with SMTP id s15mr5141291qtw.189.1635433010316; Thu, 28 Oct 2021 07:56:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWB6ZwBZnuPBexAyBrxao77rDhD9yARLzpLcsTJf9lOCOmyDxN6iWKugOQz395Y9dGn5U92A== X-Received: by 2002:a05:622a:18f:: with SMTP id s15mr5141258qtw.189.1635433010002; Thu, 28 Oct 2021 07:56:50 -0700 (PDT) Received: from [192.168.1.149] (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 g19sm2283954qtg.78.2021.10.28.07.56.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 07:56:49 -0700 (PDT) Message-ID: <450f31e5-2a99-4bda-4e4c-d38bc55e559e@redhat.com> Date: Thu, 28 Oct 2021 10:56:48 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH] c++, v2: Implement DR2351 - void{} [PR102820] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20211021084240.GE304296@tucnak> <20211028112634.GO304296@tucnak> <20211028121955.GQ304296@tucnak> From: Jason Merrill In-Reply-To: <20211028121955.GQ304296@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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, 28 Oct 2021 14:56:53 -0000 On 10/28/21 08:19, Jakub Jelinek wrote: > On Thu, Oct 28, 2021 at 08:01:27AM -0400, Jason Merrill wrote: >>> --- gcc/cp/semantics.c.jj 2021-10-27 09:16:41.161600606 +0200 >>> +++ gcc/cp/semantics.c 2021-10-28 13:06:59.325791588 +0200 >>> @@ -3079,6 +3079,24 @@ finish_unary_op_expr (location_t op_loc, >>> return result; >>> } >>> +/* Return true if CONSTRUCTOR EXPR after pack expansion could have no >>> + elements. */ >>> + >>> +static bool >>> +maybe_zero_constructor_nelts (tree expr) >>> +{ >>> + if (CONSTRUCTOR_NELTS (expr) == 0) >>> + return true; >>> + if (!processing_template_decl) >>> + return false; >>> + unsigned int i; >>> + tree val; >>> + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), i, val) >> >> Let's use >> >> for (constructor_elt &elt : CONSTRUCTOR_ELTS (t)) > > Ok, will do. > >>> @@ -3104,9 +3122,20 @@ finish_compound_literal (tree type, tree >>> if (!TYPE_OBJ_P (type)) >>> { >>> - if (complain & tf_error) >>> - error ("compound literal of non-object type %qT", type); >>> - return error_mark_node; >>> + /* DR2351 */ >>> + if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0) >>> + return void_node; >> >> This test now seems redundant with the one below (if you remove the && >> processing_template_decl). > > It is not redundant, for the maybe case it doesn't return void_node, but > falls through into if (processing_template_decl), which, because > compound_literal is necessarily instantiation_dependent_expression_p > (it contains packs) will just create CONSTRUCTOR_IS_DEPENDENT CONSTRUCTOR > and we'll get here back during instantiation. > For the CONSTRUCTOR_NELTS == 0 case even in templates we know > compound_literal isn't dependent (it doesn't contain anything) and type > isn't either, so we can return void_node right away (and when > !processing_template_decl we have to do that). Ah, right. Never mind that comment, then. Jason