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.