aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.cc
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-05-23 22:50:58 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-05-25 00:10:41 +1000
commit0173dcce92baa62a74929814a75edb75eeab1a54 (patch)
tree7c6d7211ac5767d2b89548f54f958a7455c35d17 /gcc/cp/tree.cc
parent401994d60ab38ffa9e63f368f0456eb7b08599be (diff)
downloadgcc-0173dcce92baa62a74929814a75edb75eeab1a54.zip
gcc-0173dcce92baa62a74929814a75edb75eeab1a54.tar.gz
gcc-0173dcce92baa62a74929814a75edb75eeab1a54.tar.bz2
c++/modules: Fix treatment of unnamed types
In r14-9530 we relaxed "depending on type with no-linkage" errors for declarations that could actually be accessed from different TUs anyway. However, this also enabled it for unnamed types, which never work. In a normal module interface, an unnamed type is TU-local by [basic.link] p15.2, and so cannot be exposed or the program is ill-formed. We don't yet implement this checking but we should assume that we will later; currently supporting this actually causes ICEs when attempting to create the mangled name in some situations. For a header unit, by [module.import] p5.3 it is unspecified whether two TUs importing a header unit providing such a declaration are importing the same header unit. In this case, we would require name mangling changes to somehow allow the (anonymous) type exported by such a header unit to correspond across different TUs in the presence of other anonymous declarations, so for this patch just assume that this case would be an ODR violation instead. gcc/cp/ChangeLog: * tree.cc (no_linkage_check): Anonymous types can't be accessed in a different TU. gcc/testsuite/ChangeLog: * g++.dg/modules/linkage-1_a.C: Remove anonymous type test. * g++.dg/modules/linkage-1_b.C: Likewise. * g++.dg/modules/linkage-1_c.C: Likewise. * g++.dg/modules/linkage-2.C: Add note about anonymous types. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/tree.cc')
-rw-r--r--gcc/cp/tree.cc10
1 files changed, 1 insertions, 9 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 0485a61..fe3f034 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -2988,15 +2988,7 @@ no_linkage_check (tree t, bool relaxed_p)
/* Only treat unnamed types as having no linkage if they're at
namespace scope. This is core issue 966. */
if (TYPE_UNNAMED_P (t) && TYPE_NAMESPACE_SCOPE_P (t))
- {
- if (relaxed_p
- && TREE_PUBLIC (CP_TYPE_CONTEXT (t))
- && module_maybe_has_cmi_p ())
- /* This type could possibly be accessed outside this TU. */
- return NULL_TREE;
- else
- return t;
- }
+ return t;
for (r = CP_TYPE_CONTEXT (t); ; )
{