From da8b957aca16ce42731cc3e7d16abc63d8b77b95 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Sat, 8 Feb 2014 02:40:20 +0000 Subject: [PATCH] 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 { private: using InstVisitor::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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201019 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaAccess.cpp | 7 +++---- test/SemaCXX/MicrosoftCompatibility.cpp | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp index 47aea37593..66e6e64465 100644 --- a/lib/Sema/SemaAccess.cpp +++ b/lib/Sema/SemaAccess.cpp @@ -1420,16 +1420,15 @@ static AccessResult CheckEffectiveAccess(Sema &S, 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; diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 0971646e73..a3b96da448 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -111,6 +111,9 @@ public: class B : public A { private: using A::f; + void g() { + f(); // no diagnostic + } }; class C : public B { -- 2.40.0