Page MenuHomePhabricator

[clang] Implement P0692 "Access Checking on Specializations"
AcceptedPublic

Authored by AntonBikineev on Feb 9 2018, 7:06 PM.

Details

Reviewers
rsmith
lebedev.ri
Summary

This is an attempt to implement P0692
Please note a couple of things:

  1. given that clang already suppresses access checks on explicit specializations of classes as an extension, I decided to not make the feature C++17-specific and backport it to previous standards. Not sure that this is right though;
  2. I'm also not sure that ParseOptionalCXXScopeSpecifer in a declarator is the correct place for suppressing checks.

Diff Detail

Repository
rC Clang

Event Timeline

AntonBikineev created this revision.Feb 9 2018, 7:06 PM
rsmith added a comment.Feb 9 2018, 7:20 PM

How do you avoid suppressing diagnostics in the declaration of a template that is not a partial specialization? For example:

class A { class B {}; };
template<typename T> A::B x; // error, but...
template<typename T> A::B x<T*>; // ok!

I would expect you'd need to delay the access checking diagnostics here until the declaration is complete and you find out whether you have a partial specialization or not.

@rsmith Thanks for pointing out this example. Now I see that I misunderstood the wording.
Another question is that in the provided example you say that the following line

template<typename T> A::B x<T*>; // ok!

should suppress the error of accessing private A::B. But in the wording it's said that

The usual access checking rules do not apply to non-dependent names used to specify template arguments of the simple-template-id of the partial specialization.

So it gave me the impression that only names used as template arguments should be exempted from checks. But here A::B is a non-dependent name that's part of the declaration-specifier. So is my impression wrong and names in declaration-specifiers/declarators of partial-specialiations of variable-templates should be exempted from checks as well?

Thanks.

So is my impression wrong and names in declaration-specifiers/declarators of partial-specialiations of variable-templates should be exempted from checks as well?

No, sorry, that's my error not yours.

rsmith accepted this revision.Mar 6 2018, 2:13 PM
This revision is now accepted and ready to land.Mar 6 2018, 2:13 PM