c++: Defer access checking when processing bases [PR82613]
authorPatrick Palka <ppalka@redhat.com>
Wed, 20 Jan 2021 14:43:48 +0000 (09:43 -0500)
committerPatrick Palka <ppalka@redhat.com>
Wed, 20 Jan 2021 14:43:48 +0000 (09:43 -0500)
commit79e1251b642db038df276153c9f2ec6b82e56162
treeec8ef4360954f0164fe7800a45e3b85d96079c81
parentea74a3f548eb321429c371e327e778e63d9128a0
c++: Defer access checking when processing bases [PR82613]

When parsing the base-clause of a class declaration, we need to defer
access checking until the entire base-clause has been seen, so that
access can be properly checked relative to the scope of the class with
all its bases attached.  This allows us to accept the declaration of
struct D from Example 2 of [class.access.general] (access12.C below).

Similarly when substituting into the base-clause of a class template,
which is the subject of PR82613.

gcc/cp/ChangeLog:

PR c++/82613
* parser.c (cp_parser_class_head): Defer access checking when
parsing the base-clause until all bases are seen and attached
to the class type.
* pt.c (instantiate_class_template): Likewise when substituting
into dependent bases.

gcc/testsuite/ChangeLog:

PR c++/82613
* g++.dg/parse/access12.C: New test.
* g++.dg/template/access35.C: New test.
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/parse/access12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/access35.C [new file with mode: 0644]