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.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 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=1666276718; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=5KaSADmidZpWU91uiQM4KOZmyhtmUefGn+uOLYC7MHI=; b=h0nO1So6yXUepfT6HwbEYsFoc/tTiLcEfzZ7il/v94ik0C9aYj8BcXCcqFWhhfw69Qf++4 2dfYuEwjIoQHOzRNUn01TC6OOBAGWZQb6XNsKbwDsvB+bsjALehwxeC/BSUJh1A4Id5EJ3 8OwVcAtH928keJ94aPI/43LFgEahvn0= 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 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++, v2: Fix up mangling ICE with void{} [PR106863] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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; + 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