]> granicus.if.org Git - clang/commitdiff
As per John McCall comment:
authorFrancois Pichet <pichet2000@gmail.com>
Wed, 18 Apr 2012 03:24:38 +0000 (03:24 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Wed, 18 Apr 2012 03:24:38 +0000 (03:24 +0000)
Follow up to r154924: check that we are in a static CMethodDecl to enable the Microsoft bug emulation regarding access to protected member during PTM creation. Not just any static function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154982 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaAccess.cpp

index 024838d4d4a65e32b410de5a6132c225b4e78911..01c141e57f923a88253a002709bb7ba70e406ffc 100644 (file)
@@ -781,10 +781,10 @@ static AccessResult HasAccess(Sema &S,
 
         // Emulate a MSVC bug where the creation of pointer-to-member
         // to protected member of base class is allowed but only from
-        // a static function.
-        if (S.getLangOpts().MicrosoftMode && !EC.Functions.empty() &&
-            EC.Functions.front()->getStorageClass() == SC_Static)
-           return AR_accessible;
+        // a static function member functions.
+        if (S.getLangOpts().MicrosoftMode && !EC.Functions.empty())
+          if (CXXMethodDecl* MD = dyn_cast<CXXMethodDecl>(EC.Functions.front()))
+            if (MD->isStatic()) return AR_accessible;
 
         // Despite the standard's confident wording, there is a case
         // where you can have an instance member that's neither in a