]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Don't ICE to build private access error message [PR116323]
authorSimon Martin <simon@nasilyan.com>
Tue, 10 Sep 2024 20:33:18 +0000 (22:33 +0200)
committerSimon Martin <simon@nasilyan.com>
Thu, 12 Sep 2024 08:15:23 +0000 (10:15 +0200)
commit19831baf4904d09a74c7cf684a27b091947a610b
treec31895955748f3f6356e12c816f14c6cc34fced3
parentf9e9ba9563c81ca2db99bf3daa6511c1471f1b78
c++: Don't ICE to build private access error message [PR116323]

We currently ICE upon the following code while building the "[...] is
private within this context" error message

=== cut here ===
class A { enum Enum{}; };
template<typename E, template<typename> class Alloc>
class B : private Alloc<E>, private A {};
template<typename E, template<typename> class Alloc>
int B<E, Alloc>::foo (Enum m) { return 42; }
=== cut here ===

The problem is that since r11-6880, after detecting that Enum cannot be
accessed in B, enforce_access will access the TYPE_BINFO of all the
bases of B, which ICEs for any that is a BOUND_TEMPLATE_TEMPLATE_PARM.
This patch simply skips such bases.

PR c++/116323

gcc/cp/ChangeLog:

* search.cc (get_parent_with_private_access): Only call access_in_type
for RECORD_OR_UNION_TYPE_P base BINFOs.

gcc/testsuite/ChangeLog:

* g++.dg/template/access43.C: New test.
gcc/cp/search.cc
gcc/testsuite/g++.dg/template/access43.C [new file with mode: 0644]