]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Don't treat template parameters as TU-local [PR118846]
authorNathaniel Shead <nathanieloshead@gmail.com>
Wed, 12 Feb 2025 08:15:22 +0000 (19:15 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 15 Feb 2025 12:30:09 +0000 (23:30 +1100)
commit9f1f4efc06f43b1ba8c1cf5a31d5b73d6a2bb12d
tree970245a15f6640dbee6efd2797caf21067409bb8
parent741073460b9a850ca85b01509e08bf72900b6c8a
c++/modules: Don't treat template parameters as TU-local [PR118846]

There are two separate issues making various template parameters behave
as if they were TU-local.

Firstly, the TU-local detection code uses WILDCARD_TYPE_P to check for
types that are not yet concrete; for some reason UNBOUND_CLASS_TEMPLATE
is not on that list.  I don't see any particular reason why it shouldn't
be, so this patch adds it; this may solve other latent issues as well.

Secondly, the TEMPLATE_DECL for a type with expressions involving
TEMPLATE_TEMPLATE_PARM_Ps is currently always constrained to internal
linkage, because the result does not have TREE_PUBLIC set. Rather than
messing with TREE_PUBLIC here, I think rather we just should ensure that
we only attempt to constrain visiblity of templates of type, variable,
or function decls.

PR c++/118846

gcc/cp/ChangeLog:

* cp-tree.h (WILDCARD_TYPE_P): Include UNBOUND_CLASS_TEMPLATE.
* decl2.cc (min_vis_expr_r): Don't assume a TEMPLATE_DECL will
be a function or variable.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr118846_a.C: New test.
* g++.dg/modules/pr118846_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/cp-tree.h
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/modules/pr118846_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr118846_b.C [new file with mode: 0644]