[PATCH 1/2] c++: Improve access checking inside templates [PR41437]

Jason Merrill jason@redhat.com
Thu Jun 11 22:12:31 GMT 2020


On 6/5/20 5:16 PM, Patrick Palka wrote:
> This patch generalizes our existing functionality for deferring access
> checking of typedefs when parsing a function or class template to now
> defer all kinds of access checks until template instantiation time,
> including member function and member object accesses.
> 
> Since all access checks eventually go through enforce_access, the main
> component of this patch is new handling inside enforce_access to defer
> the current access check if we're inside a template.  The bulk of the
> rest of the patch consists of removing now-unneeded code pertaining to
> suppressing access checks inside templates or pertaining to
> typedef-specific access handling.  Renamings and other changes with no
> functional impact have been split off into the followup patch.

Great!

> Bootstrapped and regtested on x86_64-pc-linux-gnu, and also tested by
> building parts of boost, cmcstl2 and other libraries.

> -      && !dependent_type_p (qualifying_type))
> +      && !dependent_type_p (scope))

This needs a comment.  And it occurs to me that if we're only going to 
check access if scope is non-dependent, we can check that much earlier 
and avoid the need to guard DECL_NONSTATIC_MEMBER_P.

Jason



More information about the Gcc-patches mailing list