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: 184822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5200419dyb; Wed, 3 Jan 2024 10:49:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzs0SNUXnFUYqeqPzY+GSFz56ztskzL1s+a03YcIiDbrFTrMKON08q+hhlQN6ldiI4w6k5 X-Received: by 2002:ae9:c019:0:b0:781:e4fb:4a49 with SMTP id u25-20020ae9c019000000b00781e4fb4a49mr2106630qkk.26.1704307798614; Wed, 03 Jan 2024 10:49:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704307798; cv=pass; d=google.com; s=arc-20160816; b=B51efNQVLDDMr/Op+hwG6RLWRUUbreB0d2hGRp8NLYsIOQ0dVmaiJRmStUNJhs2y7C ING7O+e7wbQt8aJu+iwWQL3hLtbUezuQg8OBGaxtaVQxCpjEh0nOsH0h3QTwO6oKym5t pLSBoWD84MppKYPYOCE5VHPT1XxWLWLVDcmjnfCjjRMLap/VLWmv0UiYjeXOr/S28tYW L8HXCCkS4pazZ8keDjgknuh3+0go1pCdbjdNf2d3sSNjYen+j1sHTGe6CQfkf2TTRe8n +Fn7S7pOMrsNxMZtn+A6dx//y7BcuOhK6luJI3izXWveiUlsMsJLJJR6Ft0eiDcI8ldJ jEyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=GMxGS19x1wmOJATuD76C/KjVNz766wHHYxTYQ5i7NaQ=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=NwCBb47gov/d6gehqbv0+zxh9LibkyDrl2A9lmLr60mwZ6fqUHhfDE3qC9qSeJeUt2 uFxShkmxqBoNMWJ8Yj0r0GiMxuiCr2ZlvyUxrUNLsXbqmnDKL+KU1EzkUvrTMB1NlRFK H4JWo6JjLTIeJSF+DQFFBJdnmoYjMjiOEapLJ5scUazirxjpOvVOOArvmscrMz8iV5G0 T8wJJXPHaNRSdaB9gHAILCOdPvf9cJ5J5IZZD+EUYuPhvMP5GJiVESA2GZIf9gpk5tsQ g7MhsxspW8+QudV7XCGS8Gk5PPYkOcOhrP6lPt+QCcujCT2+V6oxjrkG9v6U5hK4+dKm TDaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G7NpmbDe; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f8-20020a05620a280800b00781cac14dfdsi6855209qkp.705.2024.01.03.10.49.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 10:49:58 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=G7NpmbDe; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 533713858284 for ; Wed, 3 Jan 2024 18:49:58 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787096254414385711 X-GMAIL-MSGID: 1787096254414385711 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;