From patchwork Wed Jan 3 18:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1882172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G7NpmbDe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T4zKf4c3Rz1yQ5 for ; Thu, 4 Jan 2024 05:49:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54F813858C62 for ; Wed, 3 Jan 2024 18:49:36 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id CE4B13858C62 for ; Wed, 3 Jan 2024 18:49:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE4B13858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE4B13858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704307758; cv=none; b=nYVaHR48WKOq977AmSyCTF+EMWVKrYBTaQl02QlzP7BZpz9CMFkVfspAxwUy625Fl/pnnL+qdsNmnMIHj6Q88vPGH15iFw/BbBYrl8jJe1uMrHfhXFXI0Hogamr7LVuzh7YKVTO5TIa19ORPwawcrQW5GhxvuyRcV5oNr/Bze/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704307758; c=relaxed/simple; bh=3HNQlYAzTYR7vWBJp6SMYwKPDG/VZ7tR+9NGL8cDDhw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nJNYLaC8eOcWwBBA1bsO8CC2R0ZJrldmI9hLxH2/yb6b+TPrDVwdcEzw9LaQqYJH4RYos6SQW7qU4CR56vLAAYmux5MsOgQ7TP8aT4DPOwRjnB5FWdlD7IuVodgqKPu64/10DSii9VQ8xKg6k0gZtjuSbGZAHFtnzDC3ndmCUyU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704307754; 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; bh=GMxGS19x1wmOJATuD76C/KjVNz766wHHYxTYQ5i7NaQ=; b=G7NpmbDeyFae9Hz+yHYFMG58QgdKJTmocVVrw0xhpziXnKYJJSThwqreLxA6qpeaxHcJRX VSHnt8G3fXx/iU4GH512SG/D001/p2xPiZia/f+jS6gV0tFRkVAtz8ho3040Fh1uY9FU3P uus/BviNMjn6mTVT6GedXGkSObtJv7s= 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_256_GCM_SHA384) id us-mta-628-KsPzjx54NG2c8QIK5WQjGg-1; Wed, 03 Jan 2024 13:49:13 -0500 X-MC-Unique: KsPzjx54NG2c8QIK5WQjGg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-680971002e3so12681296d6.0 for ; Wed, 03 Jan 2024 10:49:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704307752; x=1704912552; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GMxGS19x1wmOJATuD76C/KjVNz766wHHYxTYQ5i7NaQ=; b=cScme2GIdEzXSQDgnr6zMIVWKfa6j1o5+DLpiPf7MSUaYuTEsG6wKOeBlq8hzbXa2s /kxtr4n5u4r5c/qB5Q+0adig1XxE3anzhZMVxWQkGgqI0qpWqyEdtDOGtsDirM03CErg HjNkiyBvzYWs3wiRvex5KO6OJnWDOjOAaylagYUEToDxKtnoQ+IR9uT0iXTWJ2adp4sl hktRl4NGcogDCaTfQtsqnDNbiOzOnWZFFULdDa/JosvfRcDI4RgGpAfJmkGfjnVu+Mt5 Wj2VX1uaBkL+/EbSGx70qnurmQ6C2JbJ3txyTDzgogDIQ4Rqk+zrZ3GS7UKp7twTBdUU 9dmg== X-Gm-Message-State: AOJu0YydA+ighvntOrNjs2XtEqg12Mzo/dCTiIXUZzITDkYJ0itlkZ0N l6Ls98ySu+tfVyQ6Josuy49s0Kg3yw75z3f2ZtItj3rw7Qq7QRcSmzT0A362ZmiwdI2efBetde6 NSHPnqeocVxFBDj9sLmt/pAYdoiZvHHE/gyU9l6V9i/eqTkMiwMqs2KkSgKjo0zCvN9tWjOkPLU PwLRbjuiE= X-Received: by 2002:a0c:fd43:0:b0:680:d1e4:44ad with SMTP id j3-20020a0cfd43000000b00680d1e444admr1065639qvs.21.1704307752012; Wed, 03 Jan 2024 10:49:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZzXe37YG7E0z2fnDYKijRY26SSWCUXPv1XCWn/LcQ0sE8tu3QmNcIjuaUUXlhcAbLXH2qGw== X-Received: by 2002:a0c:fd43:0:b0:680:d1e4:44ad with SMTP id j3-20020a0cfd43000000b00680d1e444admr1065627qvs.21.1704307751677; Wed, 03 Jan 2024 10:49:11 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id u10-20020a0cee8a000000b00680c9b1a407sm878251qvr.116.2024.01.03.10.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 10:49:11 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: explicit inst w/ many constrained partial specs [PR104634] Date: Wed, 3 Jan 2024 13:49:06 -0500 Message-ID: <20240103184906.2568371-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.254.ga26002b628 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk and perhaps 13? -- >8 -- Here we neglect to emit the definitions of A::f2 and A::f4 despite the explicit instantiations ultimately because TREE_PUBLIC isn't set on the corresponding partial specializations, the declarations of which are created from maybe_new_partial_specialization which is responsible for disambiguating them from the first and third partial specializations (which have the same class-head but different constraints). This makes grokfndecl in turn clear TREE_PUBLIC for f2 and f4 as if they have internal linkage. This patch fixes this by setting TREE_PUBLIC appropriately for such partial specializations. PR c++/104634 gcc/cp/ChangeLog: * pt.cc (maybe_new_partial_specialization): Propagate TREE_PUBLIC to the newly created partial specialization. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-explicit-inst6.C: New test. --- gcc/cp/pt.cc | 1 + .../g++.dg/cpp2a/concepts-explicit-inst6.C | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-explicit-inst6.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index e38e7a773f0..154ac76cb65 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -980,6 +980,7 @@ maybe_new_partial_specialization (tree& type) DECL_SOURCE_LOCATION (d) = input_location; TREE_PRIVATE (d) = (current_access_specifier == access_private_node); TREE_PROTECTED (d) = (current_access_specifier == access_protected_node); + TREE_PUBLIC (d) = TREE_PUBLIC (DECL_TEMPLATE_RESULT (tmpl)); set_instantiating_module (d); DECL_MODULE_EXPORT_P (d) = DECL_MODULE_EXPORT_P (tmpl); diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-explicit-inst6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-explicit-inst6.C new file mode 100644 index 00000000000..4ac0c65c490 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-explicit-inst6.C @@ -0,0 +1,35 @@ +// PR c++/104634 +// { dg-do compile { target c++20 } } +// { dg-final { scan-assembler "_ZN1AIiE2f1Ev" } } +// { dg-final { scan-assembler "_ZN1AIdE2f2Ev" } } +// { dg-final { scan-assembler "_ZN1AIPiE2f3Ev" } } +// { dg-final { scan-assembler "_ZN1AIPdE2f4Ev" } } + +template +struct A { }; + +template requires __is_same(T, int) +struct A { + void f1() { } + static inline int m1; +}; + +template requires __is_same(T, double) +struct A { + void f2() { } +}; + +template requires __is_same(T, int) +struct A { + void f3() { } +}; + +template requires __is_same(T, double) +struct A { + void f4() { } +}; + +template struct A; +template struct A; +template struct A; +template struct A;