On Wed, Jan 3, 2024 at 1:49 PM Patrick Palka <ppa...@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 >