brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · afd8752 Raw
115 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-all2 3// Basic cases, ambiguous paths, and fields with different access4class A {5public:6  int x;  // expected-note 2{{declared here}}7protected:8  int y;  // expected-note 2{{declared here}}9private:10  int z;11};12 13struct B : A {14};15 16struct C : A {17};18 19struct W {20  int w;  // expected-note {{declared here}}21};22 23struct U : W {24};25 26struct V : W {27};28 29class D {30public:31  char w; // expected-note {{declared here}}32private:33  char x;34};35 36// Check direct inheritance and multiple paths to the same base.37class E : B, C, D, U, V38{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 inheritance46struct F : virtual A {47};48 49struct G : virtual A {50};51 52class 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 inheritance59struct I {60  union {61    int x;  // expected-note {{declared here}}62    int y;63  };64};65 66struct 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 paths71class N : W {72};73 74struct K {75  int y;76};77 78struct L : private K {79};80 81struct M : L {82  int y;83  int w;84};85 86// Multiple ambiguous paths with different accesses87struct A1 {88  int x;  // expected-note {{declared here}}89};90 91class B1 : A1 {92};93 94struct B2 : A1 {95};96 97struct C1 : B1, B2 {98};99 100class D1 : C1 {101};102 103struct D2 : C1 {104};105 106class D3 : C1 {107};108 109struct 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