r201019 - Move the -fms-compatibility using decl check after real access checking
Reid Kleckner
reid at kleckner.net
Fri Feb 7 18:40:21 PST 2014
Author: rnk
Date: Fri Feb 7 20:40:20 2014
New Revision: 201019
URL: http://llvm.org/viewvc/llvm-project?rev=201019&view=rev
Log:
Move the -fms-compatibility using decl check after real access checking
Summary:
This avoids false positives from -Wmicrosoft when name lookup would
normally succeed in standard C++. This triggered on a common CRTP
pattern in clang, where a derived class would have a private using decl
to pull in members of a dependent base:
class Verifier : InstVisitor<Verifier> {
private:
using InstVisitor<Verifier>::visit;
...
void anything() {
visit(); // warned here
}
};
Real access checks pass here because we're in the context of the
Verifier, but the -Wmicrosoft extension was just looking for the private
access specifier.
Reviewers: rsmith
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2679
Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=201019&r1=201018&r2=201019&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Fri Feb 7 20:40:20 2014
@@ -1420,16 +1420,15 @@ static AccessResult CheckEffectiveAccess
AccessTarget &Entity) {
assert(Entity.getAccess() != AS_public && "called for public access!");
- if (S.getLangOpts().MSVCCompat &&
- IsMicrosoftUsingDeclarationAccessBug(S, Loc, Entity))
- return AR_accessible;
-
switch (IsAccessible(S, EC, Entity)) {
case AR_dependent:
DelayDependentAccess(S, EC, Loc, Entity);
return AR_dependent;
case AR_inaccessible:
+ if (S.getLangOpts().MSVCCompat &&
+ IsMicrosoftUsingDeclarationAccessBug(S, Loc, Entity))
+ return AR_accessible;
if (!Entity.isQuiet())
DiagnoseBadAccess(S, Loc, EC, Entity);
return AR_inaccessible;
Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=201019&r1=201018&r2=201019&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Fri Feb 7 20:40:20 2014
@@ -111,6 +111,9 @@ public:
class B : public A {
private:
using A::f;
+ void g() {
+ f(); // no diagnostic
+ }
};
class C : public B {
More information about the cfe-commits
mailing list