xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class.derived/class.member.lookup/p6.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class V {
4*f4a2713aSLionel Sambuc public:
5*f4a2713aSLionel Sambuc   int f();
6*f4a2713aSLionel Sambuc   int x;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc class W {
10*f4a2713aSLionel Sambuc public:
11*f4a2713aSLionel Sambuc   int g(); // expected-note{{member found by ambiguous name lookup}}
12*f4a2713aSLionel Sambuc   int y; // expected-note{{member found by ambiguous name lookup}}
13*f4a2713aSLionel Sambuc };
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc class B : public virtual V, public W
16*f4a2713aSLionel Sambuc {
17*f4a2713aSLionel Sambuc public:
18*f4a2713aSLionel Sambuc   int f();
19*f4a2713aSLionel Sambuc   int x;
20*f4a2713aSLionel Sambuc   int g();  // expected-note{{member found by ambiguous name lookup}}
21*f4a2713aSLionel Sambuc   int y; // expected-note{{member found by ambiguous name lookup}}
22*f4a2713aSLionel Sambuc };
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc class C : public virtual V, public W { };
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc class D : public B, public C { void glorp(); };
27*f4a2713aSLionel Sambuc 
glorp()28*f4a2713aSLionel Sambuc void D::glorp() {
29*f4a2713aSLionel Sambuc   x++;
30*f4a2713aSLionel Sambuc   f();
31*f4a2713aSLionel Sambuc   y++; // expected-error{{member 'y' found in multiple base classes of different types}}
32*f4a2713aSLionel Sambuc   g(); // expected-error{{member 'g' found in multiple base classes of different types}}
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // PR6462
rdbufBaseIO36*f4a2713aSLionel Sambuc struct BaseIO { BaseIO* rdbuf() { return 0; } };
rdbufPcommon37*f4a2713aSLionel Sambuc struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } };
38*f4a2713aSLionel Sambuc struct P : virtual BaseIO, Pcommon {};
39*f4a2713aSLionel Sambuc 
f()40*f4a2713aSLionel Sambuc void f() { P p; p.rdbuf(); }
41