xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct A {};
4*f4a2713aSLionel Sambuc struct E {};
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc struct R {
7*f4a2713aSLionel Sambuc     operator A*();
8*f4a2713aSLionel Sambuc     operator E*();	// expected-note{{candidate function}}
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct S {
13*f4a2713aSLionel Sambuc     operator A*();
14*f4a2713aSLionel Sambuc     operator E*();	// expected-note{{candidate function}}
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc struct B  : R {
18*f4a2713aSLionel Sambuc     operator A*();
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc struct C : B {
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc };
24*f4a2713aSLionel Sambuc 
foo(C c,int A::* pmf)25*f4a2713aSLionel Sambuc void foo(C c, int A::* pmf) {
26*f4a2713aSLionel Sambuc 	int i = c->*pmf;
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc struct B1  : R, S {
30*f4a2713aSLionel Sambuc     operator A*();
31*f4a2713aSLionel Sambuc };
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc struct C1 : B1 {
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc };
36*f4a2713aSLionel Sambuc 
foo1(C1 c1,int A::* pmf)37*f4a2713aSLionel Sambuc void foo1(C1 c1, int A::* pmf) {
38*f4a2713aSLionel Sambuc         int i = c1->*pmf;
39*f4a2713aSLionel Sambuc         c1->*pmf = 10;
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
foo1(C1 c1,int E::* pmf)42*f4a2713aSLionel Sambuc void foo1(C1 c1, int E::* pmf) {
43*f4a2713aSLionel Sambuc         int i = c1->*pmf;	// expected-error {{use of overloaded operator '->*' is ambiguous}} \
44*f4a2713aSLionel Sambuc                                 // expected-note {{because of ambiguity in conversion of 'C1' to 'E *'}} \
45*f4a2713aSLionel Sambuc                                 // expected-note 4 {{built-in candidate operator}}
46*f4a2713aSLionel Sambuc }
47