aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-01-08 10:02:04 -0500
committerPatrick Palka <ppalka@redhat.com>2021-01-08 10:02:04 -0500
commit98a1fb705ead9258642f2dec0431f11508a9b13c (patch)
tree84788f3c172bcaa2186c829f65a5efa4e8602346 /gcc/function.c
parent76be18f442948d1a4bc49a7d670b07097f9e5983 (diff)
downloadgcc-98a1fb705ead9258642f2dec0431f11508a9b13c.zip
gcc-98a1fb705ead9258642f2dec0431f11508a9b13c.tar.gz
gcc-98a1fb705ead9258642f2dec0431f11508a9b13c.tar.bz2
c++: Fix access checking of scoped non-static member [PR98515]
In the first testcase below, we incorrectly reject the use of the protected non-static member A::var0 from C<int>::g() because check_accessibility_of_qualified_id, at template parse time, determines that the access doesn't go through 'this'. (This happens because the dependent base B<T> of C<T> doesn't have a binfo object, so it appears to DERIVED_FROM_P that A is not an indirect base of C<T>.) From there we create the corresponding deferred access check, which we then perform at instantiation time and which (expectedly) fails. The problem ultimately seems to be that we can't in general determine whether a use of a scoped non-static member goes through 'this' until instantiation time, as the second testcase below illustrates. So this patch makes check_accessibility_of_qualified_id punt in such situations to avoid creating a bogus deferred access check. gcc/cp/ChangeLog: PR c++/98515 * semantics.c (check_accessibility_of_qualified_id): Punt if we're checking access of a scoped non-static member inside a class template. gcc/testsuite/ChangeLog: PR c++/98515 * g++.dg/template/access32.C: New test. * g++.dg/template/access33.C: New test.
Diffstat (limited to 'gcc/function.c')
0 files changed, 0 insertions, 0 deletions