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 3828A38515FB for ; Thu, 20 Oct 2022 14:45:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3828A38515FB 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=1666277156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UFparB9vIOzxGJdNgJjahb4LL3HcTi2ZgI7pwV6KI3A=; b=Yq04ucz4ZQtscZoIGsVM8nz8fuPQlwZP5EbnDdoJSj2D1Uu7NrVMfHVc37g6cSjJw92B7B dAtXvqI6vZKyp2J/y3hAeHggM0HZ6OQdD7Ake0YYYEb9snQ/1YjEVaEXW5vPmBGCupzcUP iOaT7EVCczXlK5txMb9sNT9ITB8dK1Y= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-616-09sfjefSMXiOKWioSuvB9w-1; Thu, 20 Oct 2022 10:45:55 -0400 X-MC-Unique: 09sfjefSMXiOKWioSuvB9w-1 Received: by mail-qv1-f71.google.com with SMTP id dn14-20020a056214094e00b004b1a231394eso13014621qvb.13 for ; Thu, 20 Oct 2022 07:45:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UFparB9vIOzxGJdNgJjahb4LL3HcTi2ZgI7pwV6KI3A=; b=XgtIuR/4tp5nvMBWnk1Fm6mWJZ+tA0xo14w1roYF7Xi//Yfa+bEYaoztXw/qxjuQ8X 9gA8ZpNJRBsz4SjNDB0ppquEFNXfZrIlOB+q4M+XJVpBL9uXtNqMubfpga0Lk2KcrxDb JueMujJtHkMcyGuo1k2+OT+1G4e7fupuo/cEv2DxIT/RyXEyoFk7F4TJ6vTcn2+aEk+L h0hr4tyczoBSGUJ1LiyJOCQCfZjLyBy+fb8oR07cJGQTvfJtA8RKr5/frpllwf9Uhm+P J9nopDGre4s9WV5/N8gxksKRSkx6Zq1Xd26KwnCKNPz5Ko+/wMC3A+ZbDP71lKuZxzan tBBQ== X-Gm-Message-State: ACrzQf0mRNEV45swaYfrseLPJ9kykCak27QDGnRYbun06kjmP0GqHwe3 TgWqDX6umG1EEBuQ9sl8cuksEj2KcdqQkbLRVXRp7XjTE//iH5bX25tZRujqW0n+y7soWO1QccY DZJwAAvpn+sVE6QhTmA== X-Received: by 2002:a05:620a:438d:b0:6e2:a30c:25d1 with SMTP id a13-20020a05620a438d00b006e2a30c25d1mr9605146qkp.155.1666277154815; Thu, 20 Oct 2022 07:45:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7cI20LQ4slIjoi5ZfkSZ2zM/V/iZrqL5gE++VgHC6vfPgYDxq2odTlyIJpMrtbz3oVrCxfdQ== X-Received: by 2002:a05:620a:438d:b0:6e2:a30c:25d1 with SMTP id a13-20020a05620a438d00b006e2a30c25d1mr9605122qkp.155.1666277154503; Thu, 20 Oct 2022 07:45:54 -0700 (PDT) Received: from [192.168.1.101] (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 t16-20020a37ea10000000b006ecc5f5635dsm7293436qkj.113.2022.10.20.07.45.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Oct 2022 07:45:53 -0700 (PDT) Message-ID: <65f645a9-5930-0752-0d1d-10e0aa8b47ad@redhat.com> Date: Thu, 20 Oct 2022 10:45:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH] c++, v2: Fix up mangling ICE with void{} [PR106863] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <6e993e48-8fff-e62b-f86b-e7359c17e62a@redhat.com> From: Jason Merrill In-Reply-To: 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=-6.7 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_NONE,RCVD_IN_MSPIKE_H2,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: On 10/20/22 10:38, Jakub Jelinek wrote: > On Thu, Oct 20, 2022 at 10:19:59AM -0400, Jason Merrill wrote: >> I think in a template we want the same early-return behavior as in the >> processing_template_decl block farther down in the function: specifically, >> we want to return a CONSTRUCTOR (for which COMPOUND_LITERAL_P is true), so >> it mangles as void{} rather than void(). > > So like this then? > > 2022-10-20 Jakub Jelinek > > PR c++/106863 > * semantics.cc (finish_compound_literal): For void{}, if > processing_template_decl return a COMPOUND_LITERAL_P > CONSTRUCTOR rather than void_node. > > * g++.dg/cpp0x/dr2351-2.C: New test. > > --- gcc/cp/semantics.cc.jj 2022-10-19 01:14:58.343483355 +0200 > +++ gcc/cp/semantics.cc 2022-10-20 16:32:30.605571968 +0200 > @@ -3164,7 +3164,16 @@ finish_compound_literal (tree type, tree > { > /* DR2351 */ > if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0) > - return void_node; > + { > + if (!processing_template_decl) > + return void_node; > + TREE_TYPE (compound_literal) = type; > + TREE_HAS_CONSTRUCTOR (compound_literal) = 1; > + CONSTRUCTOR_IS_DEPENDENT (compound_literal) = 0; > + if (fcl_context == fcl_c99) > + CONSTRUCTOR_C99_COMPOUND_LITERAL (compound_literal) = 1; I don't think it's possible to get here with the C compound literal syntax, so you can drop these two lines. OK with that change. > + return compound_literal; > + } > else if (VOID_TYPE_P (type) > && processing_template_decl > && maybe_zero_constructor_nelts (compound_literal)) > --- gcc/testsuite/g++.dg/cpp0x/dr2351-2.C.jj 2022-10-20 16:27:19.645821706 +0200 > +++ gcc/testsuite/g++.dg/cpp0x/dr2351-2.C 2022-10-20 16:27:19.645821706 +0200 > @@ -0,0 +1,16 @@ > +// DR2351 > +// { dg-do compile { target c++11 } } > + > +void bar (int); > + > +template > +auto foo (T t) -> decltype (bar (t), void{}) > +{ > + return bar (t); > +} > + > +int > +main () > +{ > + foo (0); > +} > > > Jakub >