1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-all 2 3 // Basic cases, ambiguous paths, and fields with different access 4 class A { 5 public: 6 int x; // expected-note 2{{declared here}} 7 protected: 8 int y; // expected-note 2{{declared here}} 9 private: 10 int z; 11 }; 12 13 struct B : A { 14 }; 15 16 struct C : A { 17 }; 18 19 struct W { 20 int w; // expected-note {{declared here}} 21 }; 22 23 struct U : W { 24 }; 25 26 struct V : W { 27 }; 28 29 class D { 30 public: 31 char w; // expected-note {{declared here}} 32 private: 33 char x; 34 }; 35 36 // Check direct inheritance and multiple paths to the same base. 37 class E : B, C, D, U, V 38 { 39 unsigned x; // expected-warning {{non-static data member 'x' of 'E' shadows member inherited from type 'A'}} 40 char y; // expected-warning {{non-static data member 'y' of 'E' shadows member inherited from type 'A'}} 41 double z; 42 char w; // expected-warning {{non-static data member 'w' of 'E' shadows member inherited from type 'D'}} expected-warning {{non-static data member 'w' of 'E' shadows member inherited from type 'W'}} 43 }; 44 45 // Virtual inheritance 46 struct F : virtual A { 47 }; 48 49 struct G : virtual A { 50 }; 51 52 class H : F, G { 53 int x; // expected-warning {{non-static data member 'x' of 'H' shadows member inherited from type 'A'}} 54 int y; // expected-warning {{non-static data member 'y' of 'H' shadows member inherited from type 'A'}} 55 int z; 56 }; 57 58 // Indirect inheritance 59 struct I { 60 union { 61 int x; // expected-note {{declared here}} 62 int y; 63 }; 64 }; 65 66 struct J : I { 67 int x; // expected-warning {{non-static data member 'x' of 'J' shadows member inherited from type 'I'}} 68 }; 69 70 // non-access paths 71 class N : W { 72 }; 73 74 struct K { 75 int y; 76 }; 77 78 struct L : private K { 79 }; 80 81 struct M : L { 82 int y; 83 int w; 84 }; 85 86 // Multiple ambiguous paths with different accesses 87 struct A1 { 88 int x; // expected-note {{declared here}} 89 }; 90 91 class B1 : A1 { 92 }; 93 94 struct B2 : A1 { 95 }; 96 97 struct C1 : B1, B2 { 98 }; 99 100 class D1 : C1 { 101 }; 102 103 struct D2 : C1 { 104 }; 105 106 class D3 : C1 { 107 }; 108 109 struct E1 : D1, D2, D3{ 110 int x; // expected-warning {{non-static data member 'x' of 'E1' shadows member inherited from type 'A1'}} 111 }; 112 113 114 115