[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / accessible-base.cpp
blob6b55f1474a9c1ee4e924263090c27a710d020e90
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -DMS -fms-compatibility -Wmicrosoft-inaccessible-base -fsyntax-only -verify %s
4 struct A {
5 int a;
6 };
8 struct X1 : virtual A
9 {};
11 struct Y1 : X1, virtual A
12 {};
14 struct Y2 : X1, A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Y2 -> X1 -> A\n struct Y2 -> A}}
15 {};
17 struct X2 : A
18 {};
20 struct Z1 : X2, virtual A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Z1 -> X2 -> A\n struct Z1 -> A}}
21 {};
23 struct Z2 : X2, A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Z2 -> X2 -> A\n struct Z2 -> A}}
24 {};
26 A *y2_to_a(Y2 *p) {
27 #ifdef MS
28 // expected-warning@+4 {{accessing inaccessible direct base 'A' of 'Y2' is a Microsoft extension}}
29 #else
30 // expected-error@+2 {{ambiguous conversion}}
31 #endif
32 return p;
35 A *z1_to_a(Z1 *p) {
36 #ifdef MS
37 // expected-warning@+4 {{accessing inaccessible direct base 'A' of 'Z1' is a Microsoft extension}}
38 #else
39 // expected-error@+2 {{ambiguous conversion}}
40 #endif
41 return p;
44 A *z1_to_a(Z2 *p) {
45 #ifdef MS
46 // expected-warning@+4 {{accessing inaccessible direct base 'A' of 'Z2' is a Microsoft extension}}
47 #else
48 // expected-error@+2 {{ambiguous conversion}}
49 #endif
50 return p;