[cfe-commits] r154924 - in /cfe/trunk: lib/Sema/SemaAccess.cpp test/Parser/MicrosoftExtensions.cpp
Francois Pichet
pichet2000 at gmail.com
Tue Apr 17 05:35:06 PDT 2012
Author: fpichet
Date: Tue Apr 17 07:35:05 2012
New Revision: 154924
URL: http://llvm.org/viewvc/llvm-project?rev=154924&view=rev
Log:
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.
This fixes a regression when parsing MFC code with clang.
Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=154924&r1=154923&r2=154924&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Tue Apr 17 07:35:05 2012
@@ -779,6 +779,13 @@
// that the naming class has to be derived from the effective
// context.
+ // 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;
+
// Despite the standard's confident wording, there is a case
// where you can have an instance member that's neither in a
// pointer-to-member expression nor in a member access: when
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=154924&r1=154923&r2=154924&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Tue Apr 17 07:35:05 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fdelayed-template-parsing
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -284,3 +284,28 @@
missing_template_keyword<int>();
}
+
+
+
+namespace access_protected_PTM {
+
+class A {
+protected:
+ void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
+};
+
+class B : public A{
+public:
+ void test_access();
+ static void test_access_static();
+};
+
+void B::test_access() {
+ &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
+}
+
+void B::test_access_static() {
+ &A::f;
+}
+
+}
\ No newline at end of file
More information about the cfe-commits
mailing list