summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-02-08 02:40:20 +0000
committerReid Kleckner <reid@kleckner.net>2014-02-08 02:40:20 +0000
commit42063b0b1cc6dfb91fca302ac1a1e3432287ba32 (patch)
tree240de6e8c1996ca4ec1f494dc36b447b2a200292
parent04d6d2f2af6de891688ee107b672aa2fb612204a (diff)
downloadbcm5719-llvm-42063b0b1cc6dfb91fca302ac1a1e3432287ba32.tar.gz
bcm5719-llvm-42063b0b1cc6dfb91fca302ac1a1e3432287ba32.zip
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 llvm-svn: 201019
-rw-r--r--clang/lib/Sema/SemaAccess.cpp7
-rw-r--r--clang/test/SemaCXX/MicrosoftCompatibility.cpp3
2 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index 47aea375939..66e6e644655 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/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/clang/test/SemaCXX/MicrosoftCompatibility.cpp b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
index 0971646e73b..a3b96da448c 100644
--- a/clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/clang/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 {
OpenPOWER on IntegriCloud