From patchwork Wed Oct 19 08:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 4469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp188982wrs; Wed, 19 Oct 2022 01:01:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GWx4TiWm67YzJ7J7OcnLHW0JFzehJ/C5efgKHBpOSnFnwAmo4qOP7wgLhPVy8moRM5gQQ X-Received: by 2002:a17:907:e88:b0:78d:fb98:6f5d with SMTP id ho8-20020a1709070e8800b0078dfb986f5dmr5661788ejc.5.1666166490444; Wed, 19 Oct 2022 01:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666166490; cv=none; d=google.com; s=arc-20160816; b=msHlt6I61tBs6k3Sevnj8CDVyE0IKi2lo63uHSqZkAPjq7x6Ya0MsTdvT3D8L1adr/ ozHvNoI73RV4rFuQ7h2Wk2ssg4eVqSAZ0vtZSuvF7BBp7QwqfScrKwcFz8pmw7fOX4Y5 ffJpMEWrLw2q8nnSoR5eiDtCsMXA44YxK6sN1AeSAIyhWIQmeX7Hnx66MlrvEjp3oqvV GLF0iuhuPPKbIfNlDyO7GJznjZrQL1rVP1T3NlukbVZlVHK+YtsRXCZOUv3mSe4Sm64X kQRzBdMoLYz4ZvWg6lDU47pmskZxYPEMsV/SHW3JbFi5WQbYRxU4xJq1aM+QBxWLFXBX Oucw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=BpwJKrWpnKrYMxHYF8FyGD7NArEv8neuuisvRot5I3g=; b=vm2E4//xynVtBuks7+S1Nk+qJ3lMTYqRpnQy1EBFILxNycKQ3zJ7AhLTe9LypSSn70 pI87T4gvAqVk2lN8zDxDwTAPIvR+nQjPzINmRMqpvuJQ6g/XaWeflxxYme81ao1HagWt DK8esiC0EGiFi+Kq4o5NICRIsWvyGdd5iXi3GmO14HnHVgJx1HpayS6fB655CGgGoyzI XyMTjRJGSfuwO/bWEuhsLS82JDJPC1M45HIgSJH3l+XhUA3AVqMHKt/8zr+I8xa4HWLz /zEUyH5tQdj1tuOumvISDNDZ1IcTu28XeoKVfXASNNpaVbIj2N/+bQDKlR1z/3xFvNrn WgXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=h6du1Glj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l18-20020a056402345200b0044e8dc744a4si11696397edc.142.2022.10.19.01.01.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 01:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=h6du1Glj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41EC23857C4B for ; Wed, 19 Oct 2022 08:01:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41EC23857C4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666166489; bh=BpwJKrWpnKrYMxHYF8FyGD7NArEv8neuuisvRot5I3g=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=h6du1GljE2Q6xiqYVpD5jDS9rZkNFykq2662oeS8CKJvp9WsFhWXjS+WBr7u9RW5+ EPHzPLjS+TSXbGS1Kvvvq1GoelGxnAhGyvnQ4tnCJBj+jZDj0v2wRL1lIF9JBrU3Hk i9VWA0ZPYX7GicwmnLZu5LZOo6fwxAcXi5Eckf0I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8D6993858D39 for ; Wed, 19 Oct 2022 08:00:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D6993858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-SJrKeZaZNdqdhMhySJbnIQ-1; Wed, 19 Oct 2022 04:00:41 -0400 X-MC-Unique: SJrKeZaZNdqdhMhySJbnIQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20A63823F74 for ; Wed, 19 Oct 2022 08:00:41 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCCCAC1908B; Wed, 19 Oct 2022 08:00:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 29J80cNE3797121 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 10:00:38 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29J80bwW3797120; Wed, 19 Oct 2022 10:00:37 +0200 Date: Wed, 19 Oct 2022 10:00:37 +0200 To: Jason Merrill Subject: [PATCH] c++: Fix up mangling ICE with void{} [PR106863] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747102193901958099?= X-GMAIL-MSGID: =?utf-8?q?1747102193901958099?= 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. 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. Jakub --- 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); +}