aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-04-29 21:27:59 -0400
committerPatrick Palka <ppalka@redhat.com>2024-04-29 21:27:59 -0400
commit22b20ac6c6aead2d3f36c413a77dd0b80adfec39 (patch)
tree871687057d22be59607e79ae7d195ce1cc9b6457 /gcc/cp/module.cc
parent3900e944b0ac9db77380c5bb8635977dfd3b0691 (diff)
downloadgcc-22b20ac6c6aead2d3f36c413a77dd0b80adfec39.zip
gcc-22b20ac6c6aead2d3f36c413a77dd0b80adfec39.tar.gz
gcc-22b20ac6c6aead2d3f36c413a77dd0b80adfec39.tar.bz2
c++/modules: imported spec befriending class tmpl [PR114889]
When adding to CLASSTYPE_BEFRIENDING_CLASSES as part of installing an imported class definition, we need to look through TEMPLATE_DECL like make_friend_class does. Otherwise in the below testcase we won't add _Hashtable<int, int> to CLASSTYPE_BEFRIENDING_CLASSES of _Map_base, which leads to a bogus access check failure for _M_hash_code. PR c++/114889 gcc/cp/ChangeLog: * module.cc (trees_in::read_class_def): Look through TEMPLATE_DECL when adding to CLASSTYPE_BEFRIENDING_CLASSES. gcc/testsuite/ChangeLog: * g++.dg/modules/friend-8_a.H: New test. * g++.dg/modules/friend-8_b.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index c35e70b..3bf863e 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12498,6 +12498,8 @@ trees_in::read_class_def (tree defn, tree maybe_template)
for (; friend_classes; friend_classes = TREE_CHAIN (friend_classes))
{
tree f = TREE_VALUE (friend_classes);
+ if (TREE_CODE (f) == TEMPLATE_DECL)
+ f = TREE_TYPE (f);
if (CLASS_TYPE_P (f))
{