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 2F6B7385084F for ; Thu, 20 Oct 2022 14:20:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F6B7385084F 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=1666275602; 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=SV4k832wuJUser8X/y+cRhNJf0f47Z5jiZba6Zvj22k=; b=PH9FFfGK/y1KZ4vx3xwAX7FfM8XvSaShDUXVPp/PZ3awyi7fz8/OUUkRmsNJwRlZDUC5Q9 jAdCVuciPXQ9c3cfFHcsgc2whCp9wpg+0/Zvc/aM84Wx6ZqUdAig82pPjItIaKXN6FEp+v UnvzOSNmx/xJrE1fWXpZ6VdFsxNFCiA= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-216-JrKvaO54NgC_pJA9-XbMZw-1; Thu, 20 Oct 2022 10:20:01 -0400 X-MC-Unique: JrKvaO54NgC_pJA9-XbMZw-1 Received: by mail-qv1-f69.google.com with SMTP id ma6-20020a0562145b0600b004b49a5037aeso12070207qvb.18 for ; Thu, 20 Oct 2022 07:20:01 -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=SV4k832wuJUser8X/y+cRhNJf0f47Z5jiZba6Zvj22k=; b=Kk8GPBt5MqjH5FJhe0crtUAayXc4UltsKIZDYYYe36NS2elHHggO3d8D4g6mi20I14 syZlduFuCsnxFPzgnqYMYThPEELDGOUQSgJ5e1abzhDqmGRP49UvIo7dmGmfN+cCtGKP C3TE5eUM8uth2RzqtrtgoPD5KTP75I5GFCrNqk+4pnNkULcbIqWvphwtlyZkFbJyvwXT FYxLs62Kmxgj3XRxjpzxtMoCdZeUMPvuiioRaoZxz9zgWGvnJT5u6zg0fJZ0u1/oRejx +W9Q6nmLEaSapJXIx6i9ZENJ3css/CdKn5ImyEJNBILvpmMnB09WwNL88kPD9VPwsuXy GaTQ== X-Gm-Message-State: ACrzQf3TZIcaTjerK93VDCyVwHN6B/qYKlbvKpTQ/qjUVCT1VBtpzI9R pRa0BGMVtPKdEs5sByAwxxhQNfytEb/YB0vuNigHneKIXj2/XUd51aMWUNBCjuQGvEszrr/yH4X Fifd/SuUWsDPw30WzPg== X-Received: by 2002:ae9:e8ce:0:b0:6ed:22ee:305e with SMTP id a197-20020ae9e8ce000000b006ed22ee305emr9180238qkg.255.1666275601287; Thu, 20 Oct 2022 07:20:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lgGbI7u3pUo0Ot1li0ZsCRCgaLAEQ7eT6Ua/jewwT4KQWvb4p8uI0fNFoNQEqSUGWbNlf6A== X-Received: by 2002:ae9:e8ce:0:b0:6ed:22ee:305e with SMTP id a197-20020ae9e8ce000000b006ed22ee305emr9180205qkg.255.1666275600991; Thu, 20 Oct 2022 07:20:00 -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 u30-20020a37ab1e000000b006ef0350db8asm1574888qke.128.2022.10.20.07.20.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Oct 2022 07:20:00 -0700 (PDT) Message-ID: <6e993e48-8fff-e62b-f86b-e7359c17e62a@redhat.com> Date: Thu, 20 Oct 2022 10:19:59 -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++: Fix up mangling ICE with void{} [PR106863] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: 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/19/22 04:00, Jakub Jelinek wrote: > Hi! > > We ICE on the following testcase during mangling, finish_compound_literal > returns for void{} void_node and the mangler doesn't handle it. > Handling void_node in the mangler seems problematic to me, because > we don't know for which case it has been created. > The following patch arranges to mangle just void{} the same as void() > if that is what we want to use, by doing what we do for void() when > processing void{}. > The code does that only if processing_template_decl, because otherwise > build_functional_cast will return void_node, so calling it looks like > wasted effort to me. But if you want to call it unconditionally, > I can certainly do that too. 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(). > Or do you want to mangle it differently? How? > > clang++ doesn't support DR2351, so I can't check what they are doing. > > Bootstrapped/regtested on x86_64-linux and i686-linux. > > 2022-10-19 Jakub Jelinek > > PR c++/106863 > * semantics.cc (finish_compound_literal): For void{}, if > processing_template_decl return build_functional_cast of NULL_TREE > to VOID_TYPE rather than void_node. > > * g++.dg/cpp0x/dr2351-2.C: New test. > > --- gcc/cp/semantics.cc.jj 2022-10-10 09:31:57.410985121 +0200 > +++ gcc/cp/semantics.cc 2022-10-18 15:24:08.726026118 +0200 > @@ -3164,7 +3164,12 @@ 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; > + location_t loc = cp_expr_loc_or_input_loc (compound_literal); > + return build_functional_cast (loc, type, NULL_TREE, complain); > + } > 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-18 15:27:01.146690132 +0200 > +++ gcc/testsuite/g++.dg/cpp0x/dr2351-2.C 2022-10-18 15:27:39.909164970 +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 >