From 5b4faeec8705aeecd9c7d5cb90ece6f50c459195 Mon Sep 17 00:00:00 2001 From: Dmitry Polukhin Date: Thu, 28 Apr 2016 09:56:22 +0000 Subject: [PATCH] Revert "[MSVC] PR27337: allow static_cast from private base to derived for WTL" This reverts commit r267534. llvm-svn: 267865 --- .../clang/Basic/DiagnosticSemaKinds.td | 3 -- clang/lib/Sema/SemaCast.cpp | 9 ++--- clang/test/SemaCXX/ext_ms_downcast.cpp | 40 ------------------- 3 files changed, 4 insertions(+), 48 deletions(-) delete mode 100644 clang/test/SemaCXX/ext_ms_downcast.cpp diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index afa741077c33..b04abc55afbb 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5764,9 +5764,6 @@ def err_static_downcast_via_virtual : Error< "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; 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< diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 84a070573f51..4a7699b22e22 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -1344,11 +1344,10 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, } 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 diff --git a/clang/test/SemaCXX/ext_ms_downcast.cpp b/clang/test/SemaCXX/ext_ms_downcast.cpp deleted file mode 100644 index 42feeb4b8cf5..000000000000 --- a/clang/test/SemaCXX/ext_ms_downcast.cpp +++ /dev/null @@ -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(p); -#ifdef NO_MS_COMPATIBILITY - // expected-error@-2 {{cannot cast private base class 'A' to 'B'}} -#else - // expected-warning@-4 {{casting from private base class 'A' to derived class 'B' is a Microsoft extension}} -#endif -} - -A* bar(B* p) { - return static_cast(p); // expected-error {{cannot cast 'B' to its private base class 'A'}} -} - -// from atlframe.h -template -class CUpdateUI { -public: - CUpdateUI() { - T* pT = static_cast(this); -#ifdef NO_MS_COMPATIBILITY - // expected-error@-2 {{cannot cast private base class}} -#else - // expected-warning@-4 {{casting from private base class 'CUpdateUI' to derived class 'CMDIFrame' is a Microsoft extension}} -#endif - } -}; - -// from sample WTL/MDIDocVw (mainfrm.h -class CMDIFrame : CUpdateUI {}; -// expected-note@-1 {{implicitly declared private here}} -// expected-note@-2 {{in instantiation of member function}} - -CMDIFrame wndMain;