aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/class.derived/class.member.lookup/p10.cpp
blob: afd87521885abc677263c33bd562b51ed0dacdf3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-all

// Basic cases, ambiguous paths, and fields with different access
class A {
public:
  int x;  // expected-note 2{{declared here}}
protected:
  int y;  // expected-note 2{{declared here}}
private:
  int z;
};

struct B : A {
};

struct C : A {
};

struct W {
  int w;  // expected-note {{declared here}}
};

struct U : W {
};

struct V : W {
};

class D {
public:
  char w; // expected-note {{declared here}}
private:
  char x;
};

// Check direct inheritance and multiple paths to the same base.
class E : B, C, D, U, V
{
  unsigned x;  // expected-warning {{non-static data member 'x' of 'E' shadows member inherited from type 'A'}}
  char y;  // expected-warning {{non-static data member 'y' of 'E' shadows member inherited from type 'A'}}
  double z;
  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'}}
};

// Virtual inheritance
struct F : virtual A {
};

struct G : virtual A {
};

class H : F, G {
  int x;  // expected-warning {{non-static data member 'x' of 'H' shadows member inherited from type 'A'}}
  int y;  // expected-warning {{non-static data member 'y' of 'H' shadows member inherited from type 'A'}}
  int z;
};

// Indirect inheritance
struct I {
  union {
    int x;  // expected-note {{declared here}}
    int y;
  };
};

struct J : I {
  int x;  // expected-warning {{non-static data member 'x' of 'J' shadows member inherited from type 'I'}}
};

// non-access paths
class N : W {
};

struct K {
  int y;
};

struct L : private K {
};

struct M : L {
  int y;
  int w;
};

// Multiple ambiguous paths with different accesses
struct A1 {
  int x;  // expected-note {{declared here}}
};

class B1 : A1 {
};

struct B2 : A1 {
};

struct C1 : B1, B2 {
};

class D1 : C1 {
};

struct D2 : C1 {
};

class D3 : C1 {
};

struct E1 : D1, D2, D3{
  int x;  // expected-warning {{non-static data member 'x' of 'E1' shadows member inherited from type 'A1'}}
};