Clang Project

clang_source_code/test/CXX/class.derived/class.member.lookup/p6.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-field
2
3class V { 
4public: 
5  int f(); 
6  int x; // expected-note {{declared here}}
7};
8
9class W { 
10public: 
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
15class B : public virtual V, public W
16{
17public:
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
24class C : public virtual V, public W { };
25
26class D : public B, public C { void glorp(); };
27
28void 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
36struct BaseIO { BaseIO* rdbuf() { return 0; } };
37struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } };
38struct P : virtual BaseIO, Pcommon {};
39
40void f() { P p; p.rdbuf(); }
41