From patchwork Thu Oct 20 14:38:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 6224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp147609wrr; Thu, 20 Oct 2022 07:39:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7iJf+F3rxTVVl6S5+uCJ1TCH0S4HbkNkS5yHOxrMDRfsWcvFka+BRvM2l8yYIATgwV27b9 X-Received: by 2002:a05:6402:3548:b0:45d:6506:990a with SMTP id f8-20020a056402354800b0045d6506990amr12459669edd.218.1666276763871; Thu, 20 Oct 2022 07:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666276763; cv=none; d=google.com; s=arc-20160816; b=g12P7x4LM+puQ/ow93Mb4xHTDSUtEUQ9JohWDnb8DC1ZFOiLnpFOPAJ+WFpw/eb0Yt XPLQLtjkZe2cGOmqdG0b+uyx+X4abB0cQP/YYx8pbBS/A6j7tiT50gIgXUtrg1sgj5jj Hm+jsTtk0kIzxpeGDO52zYp/GoQoFycMQBDRTzlmYONZkSALgLZUfc8gkum4cGP5BMFn rxztT40VTtV6W/7I/BFGn8P+tDHjtyA96+vtXPJYfRXl6iIMf+OZ9e/o66vzo46bHkmN PBuq3d2BXxyF2HUDkrvSVLFRAbR/J+Yain9NcdNyTp67y9ePbMzkNk0hoInwpmlgKFBT kS2w== 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:in-reply-to:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=5KaSADmidZpWU91uiQM4KOZmyhtmUefGn+uOLYC7MHI=; b=W8saBF/JsnXGEJEhv39FDH7yIdQ+aqJYRZ8RXPKTARej5vQL8ChXs7clwgDkxpmWB/ NOwijvVPl+x38oeFAxQGW1bMAxCLMJsJKSBHuswqcVj/rh7GlKyR+w/YzXLyyAI3PF00 tBjVz60Gn8jxAlsJ1LKL8oxg28Pv+ZHQWs+L8cZMY9c5oZKPRRHJfnq16gL96iyMzhor LhLNFuAR1MYbEdgUMUj9xyCehu1LW3u0CU3+ZGWe0MZiFk7eMulwlxs3GOPd0Kar0mSa wT4Gmn540xju/WtcpfThTItn8w8zk8+yfRD5nV+ELUyrP+ByWXHkc6QkzU8fRFD9SKny HSXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t0pwdEc4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id sc11-20020a1709078a0b00b0078c9dd279b6si15585978ejc.345.2022.10.20.07.39.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 07:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t0pwdEc4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 D3A9A385085C for ; Thu, 20 Oct 2022 14:39:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3A9A385085C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666276762; bh=5KaSADmidZpWU91uiQM4KOZmyhtmUefGn+uOLYC7MHI=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=t0pwdEc4u4aL8FGAPbJ3G0hZq7vQQ4e4V08w+sUyKmXjxPKNflslf78hB4nfFaR4k qKBnmbBvPNrviYVGLFHFItt0BSz+srUL++Vluwrs45Pp7XNBYqlGwW8XF169E1vm2o KqrgXkuP88SoPtJZn264azIWXozf3C9/dQmLDfAs= 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 89D313856172 for ; Thu, 20 Oct 2022 14:38:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89D313856172 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-407-bJnhbyw6Noyz83uUHFns8Q-1; Thu, 20 Oct 2022 10:38:36 -0400 X-MC-Unique: bJnhbyw6Noyz83uUHFns8Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90D491C0A597 for ; Thu, 20 Oct 2022 14:38:36 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B2A07AE5; Thu, 20 Oct 2022 14:38:36 +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 29KEcXQ41624066 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 16:38:34 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29KEcXdh1624065; Thu, 20 Oct 2022 16:38:33 +0200 Date: Thu, 20 Oct 2022 16:38:33 +0200 To: Jason Merrill Subject: [PATCH] c++, v2: Fix up mangling ICE with void{} [PR106863] Message-ID: References: <6e993e48-8fff-e62b-f86b-e7359c17e62a@redhat.com> MIME-Version: 1.0 In-Reply-To: <6e993e48-8fff-e62b-f86b-e7359c17e62a@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.2 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?1747217824043833417?= X-GMAIL-MSGID: =?utf-8?q?1747217824043833417?= 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. Jakub --- 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; + 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); +}