1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-field |
2 | |
3 | class V { |
4 | public: |
5 | int f(); |
6 | int x; // expected-note {{declared here}} |
7 | }; |
8 | |
9 | class W { |
10 | public: |
11 | int g(); // expected-note{{member found by ambiguous name lookup}} |
12 | int y; // expected-note{{member found by ambiguous name lookup}} expected-note {{declared here}} |
13 | }; |
14 | |
15 | class B : public virtual V, public W |
16 | { |
17 | public: |
18 | int f(); |
19 | int x; // expected-warning {{non-static data member 'x' of 'B' shadows member inherited from type 'V'}} |
20 | int g(); // expected-note{{member found by ambiguous name lookup}} |
21 | int y; // expected-note{{member found by ambiguous name lookup}} expected-warning {{non-static data member 'y' of 'B' shadows member inherited from type 'W'}} |
22 | }; |
23 | |
24 | class C : public virtual V, public W { }; |
25 | |
26 | class D : public B, public C { void glorp(); }; |
27 | |
28 | void D::glorp() { |
29 | x++; |
30 | f(); |
31 | y++; // expected-error{{member 'y' found in multiple base classes of different types}} |
32 | g(); // expected-error{{member 'g' found in multiple base classes of different types}} |
33 | } |
34 | |
35 | // PR6462 |
36 | struct BaseIO { BaseIO* rdbuf() { return 0; } }; |
37 | struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } }; |
38 | struct P : virtual BaseIO, Pcommon {}; |
39 | |
40 | void f() { P p; p.rdbuf(); } |
41 | |