blob: 07936e7eecc5be40c0ac8c2276f237c3b3ca64c1 [file] [log] [blame]
Douglas Gregor88a35142008-12-22 05:46:06 +00001// RUN: clang -fsyntax-only -verify %s
2
3struct X {
Sebastian Redl3cb06922009-02-07 19:52:04 +00004 int& f(int) const; // expected-note 2 {{candidate function}}
5 float& f(int); // expected-note 2 {{candidate function}}
Douglas Gregor88a35142008-12-22 05:46:06 +00006
7 void test_f(int x) const {
8 int& i = f(x);
9 }
10
11 void test_f2(int x) {
12 float& f2 = f(x);
13 }
14
Sebastian Redl3cb06922009-02-07 19:52:04 +000015 int& g(int) const; // expected-note 2 {{candidate function}}
16 float& g(int); // expected-note 2 {{candidate function}}
17 static double& g(double); // expected-note 2 {{candidate function}}
Douglas Gregor88a35142008-12-22 05:46:06 +000018
19 void h(int);
Douglas Gregor3f20a682009-01-12 23:20:38 +000020
21 void test_member() {
22 float& f1 = f(0);
23 float& f2 = g(0);
24 double& d1 = g(0.0);
25 }
26
27 void test_member_const() const {
28 int &i1 = f(0);
29 int &i2 = g(0);
30 double& d1 = g(0.0);
31 }
32
33 static void test_member_static() {
34 double& d1 = g(0.0);
35 g(0); // expected-error{{call to 'g' is ambiguous; candidates are:}}
36 }
Douglas Gregor88a35142008-12-22 05:46:06 +000037};
38
39void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp) {
40 int& i1 = xc.f(0);
41 int& i2 = xcp->f(0);
42 float& f1 = x.f(0);
43 float& f2 = xp->f(0);
44 xv.f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}}
45 xvp->f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}}
46
47 int& i3 = xc.g(0);
48 int& i4 = xcp->g(0);
49 float& f3 = x.g(0);
50 float& f4 = xp->g(0);
51 double& d1 = xp->g(0.0);
52 double& d2 = X::g(0.0);
53 X::g(0); // expected-error{{call to 'g' is ambiguous; candidates are:}}
54
55 X::h(0); // expected-error{{call to non-static member function without an object argument}}
56}