r267865 - Revert "[MSVC] PR27337: allow static_cast from private base to derived for WTL"

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 02:56:23 PDT 2016


Author: dpolukhin
Date: Thu Apr 28 04:56:22 2016
New Revision: 267865

URL: http://llvm.org/viewvc/llvm-project?rev=267865&view=rev
Log:
Revert "[MSVC] PR27337: allow static_cast from private base to derived for WTL"

This reverts commit r267534.

Removed:
    cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267865&r1=267864&r2=267865&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 28 04:56:22 2016
@@ -5764,9 +5764,6 @@ def err_static_downcast_via_virtual : Er
   "cannot cast %0 to %1 via virtual base %2">;
 def err_downcast_from_inaccessible_base : Error<
   "cannot cast %select{private|protected}2 base class %1 to %0">;
-def ext_ms_downcast_from_inaccessible_base : ExtWarn<
-  "casting from %select{private|protected}2 base class %1 to derived class %0 is a Microsoft extension">,
-  InGroup<MicrosoftCast>;
 def err_upcast_to_inaccessible_base : Error<
   "cannot cast %0 to its %select{private|protected}2 base class %1">;
 def err_bad_dynamic_cast_not_ref_or_ptr : Error<

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=267865&r1=267864&r2=267865&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Apr 28 04:56:22 2016
@@ -1344,11 +1344,10 @@ TryStaticDowncast(Sema &Self, CanQualTyp
   }
 
   if (!CStyle) {
-    unsigned Diag = Self.getLangOpts().MSVCCompat
-                        ? diag::ext_ms_downcast_from_inaccessible_base
-                        : diag::err_downcast_from_inaccessible_base;
-    switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType, DestType,
-                                      Paths.front(), Diag)) {
+    switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
+                                      SrcType, DestType,
+                                      Paths.front(),
+                                diag::err_downcast_from_inaccessible_base)) {
     case Sema::AR_accessible:
     case Sema::AR_delayed:     // be optimistic
     case Sema::AR_dependent:   // be optimistic

Removed: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp?rev=267864&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (original)
+++ cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (removed)
@@ -1,40 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
-
-// Minimal reproducer.
-class A {};
-class B : A {}; // expected-note 2 {{implicitly declared private here}}
-
-B* foo(A* p) {
-  return static_cast<B*>(p);
-#ifdef NO_MS_COMPATIBILITY
-  // expected-error at -2 {{cannot cast private base class 'A' to 'B'}}
-#else
-  // expected-warning at -4 {{casting from private base class 'A' to derived class 'B' is a Microsoft extension}}
-#endif
-}
-
-A* bar(B* p) {
-  return static_cast<A*>(p); // expected-error {{cannot cast 'B' to its private base class 'A'}}
-}
-
-// from atlframe.h
-template <class T>
-class CUpdateUI {
-public:
-  CUpdateUI() {
-    T* pT = static_cast<T*>(this);
-#ifdef NO_MS_COMPATIBILITY
-    // expected-error at -2 {{cannot cast private base class}}
-#else
-    // expected-warning at -4 {{casting from private base class 'CUpdateUI<CMDIFrame>' to derived class 'CMDIFrame' is a Microsoft extension}}
-#endif
-  }
-};
-
-// from sample WTL/MDIDocVw (mainfrm.h
-class CMDIFrame : CUpdateUI<CMDIFrame> {};
-// expected-note at -1 {{implicitly declared private here}}
-// expected-note at -2 {{in instantiation of member function}}
-
-CMDIFrame wndMain;




More information about the cfe-commits mailing list