[MS] Allow access to ambiguous, inaccessible direct bases
authorReid Kleckner <rnk@google.com>
Fri, 27 Oct 2017 22:48:41 +0000 (22:48 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 27 Oct 2017 22:48:41 +0000 (22:48 +0000)
commit2e87a21c7cac8931593bc281acf5a15f7cf591a0
treebe7ba16dc4c9c5d325f7ca4ce2c624e858c462e8
parente58044d4324a3431be93685071643914baa886d6
[MS] Allow access to ambiguous, inaccessible direct bases

Summary:
Clang typically warns that in the following class hierarchy, 'A' is
inaccessible because there is no series of casts that the user can
write to access it unambiguously:
  struct A { };
  struct B : A { };
  struct C : A, B { };

MSVC allows the user to convert from C* to A*, though, and we've
encountered this issue in the latest Windows SDK headers.

This patch allows this conversion when -fms-compatibility is set and
adds a warning for it under -Wmicrosoft-inaccessible-base.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D39389

llvm-svn: 316807
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp [new file with mode: 0644]
clang/test/SemaCXX/accessible-base.cpp