Message ID | 20240103184906.2568371-1-ppalka@redhat.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> 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 <ouuuleilei@gmail.com> (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 <ouuuleilei@gmail.com>; 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 <gcc-patches@gcc.gnu.org>; 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 <gcc-patches@gcc.gnu.org>; 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 <ppalka@redhat.com> To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka <ppalka@redhat.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=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 |
Series |
c++: explicit inst w/ many constrained partial specs [PR104634]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Patrick Palka
Jan. 3, 2024, 6:49 p.m. UTC
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<double>::f2 and A<double*>::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
Comments
On Wed, Jan 3, 2024 at 1:49 PM Patrick Palka <ppalka@redhat.com> wrote: > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK > for trunk and perhaps 13? Ping. > > -- >8 -- > > Here we neglect to emit the definitions of A<double>::f2 and A<double*>::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<typename T> > +struct A { }; > + > +template<class T> requires __is_same(T, int) > +struct A<T> { > + void f1() { } > + static inline int m1; > +}; > + > +template<class T> requires __is_same(T, double) > +struct A<T> { > + void f2() { } > +}; > + > +template<class T> requires __is_same(T, int) > +struct A<T*> { > + void f3() { } > +}; > + > +template<class T> requires __is_same(T, double) > +struct A<T*> { > + void f4() { } > +}; > + > +template struct A<int>; > +template struct A<double>; > +template struct A<int*>; > +template struct A<double*>; > -- > 2.43.0.254.ga26002b628 >
On 1/3/24 13:49, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK > for trunk and perhaps 13? OK for both. > -- >8 -- > > Here we neglect to emit the definitions of A<double>::f2 and A<double*>::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<typename T> > +struct A { }; > + > +template<class T> requires __is_same(T, int) > +struct A<T> { > + void f1() { } > + static inline int m1; > +}; > + > +template<class T> requires __is_same(T, double) > +struct A<T> { > + void f2() { } > +}; > + > +template<class T> requires __is_same(T, int) > +struct A<T*> { > + void f3() { } > +}; > + > +template<class T> requires __is_same(T, double) > +struct A<T*> { > + void f4() { } > +}; > + > +template struct A<int>; > +template struct A<double>; > +template struct A<int*>; > +template struct A<double*>;
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<typename T> +struct A { }; + +template<class T> requires __is_same(T, int) +struct A<T> { + void f1() { } + static inline int m1; +}; + +template<class T> requires __is_same(T, double) +struct A<T> { + void f2() { } +}; + +template<class T> requires __is_same(T, int) +struct A<T*> { + void f3() { } +}; + +template<class T> requires __is_same(T, double) +struct A<T*> { + void f4() { } +}; + +template struct A<int>; +template struct A<double>; +template struct A<int*>; +template struct A<double*>;