1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 int& f(int) const; // expected-note 2 {{candidate function}}
5 float& f(int); // expected-note 2 {{candidate function}}
7 void test_f(int x
) const {
15 int& g(int) const; // expected-note 2 {{candidate function}}
16 float& g(int); // expected-note 2 {{candidate function}}
17 static double& g(double);
27 void test_member_const() const {
33 static void test_member_static() {
35 g(0); // expected-error{{call to 'g' is ambiguous}}
39 void test(X x
, const X xc
, X
* xp
, const X
* xcp
, volatile X xv
, volatile X
* xvp
) {
44 xv
.f(0); // expected-error{{no matching member function for call to 'f'}}
45 xvp
->f(0); // expected-error{{no matching member function for call to 'f'}}
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}}
55 X::h(0); // expected-error{{call to non-static member function without an object argument}}
60 float& member() const;
65 void test_X2(X2
*x2p
, const X2
*cx2p
) {
66 int &ir
= x2p
->member();
67 float &fr
= cx2p
->member();
70 // Tests the exact text used to note the candidates
74 void foo(T t
, unsigned N
); // expected-note {{candidate function template not viable: no known conversion from 'const char[6]' to 'unsigned int' for 2nd argument}}
75 void foo(int n
, char N
); // expected-note {{candidate function not viable: no known conversion from 'const char[6]' to 'char' for 2nd argument}}
76 void foo(int n
, const char *s
, int t
); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
77 void foo(int n
, const char *s
, int t
, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
78 void foo(int n
, const char *s
, int t
, int u
= 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
80 void bar(double d
); //expected-note {{candidate function not viable: 'this' argument has type 'const A', but method is not marked const}}
81 void bar(int i
); //expected-note {{candidate function not viable: 'this' argument has type 'const A', but method is not marked const}}
83 void baz(A
&d
); // expected-note {{candidate function not viable: 1st argument ('const A') would lose const qualifier}}
84 void baz(int i
); // expected-note {{candidate function not viable: no known conversion from 'const A' to 'int' for 1st argument}}
86 void ref() &&; // expected-note {{expects an rvalue for object argument}} expected-note {{requires 0 arguments, but 1 was provided}}
87 void ref(int) &; // expected-note {{expects an lvalue for object argument}} expected-note {{requires 1 argument, but 0 were provided}}
90 void foo(int n
); // expected-note {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}}
91 void foo(unsigned n
= 10); // expected-note {{candidate function not viable: allows at most single argument 'n', but 2 arguments were provided}}
92 void rab(double n
, int u
= 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}}
93 void rab(int n
, int u
= 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}}
94 void zab(double n
= 0.0, int u
= 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}}
95 void zab(int n
= 0, int u
= 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}}
100 a
.foo(4, "hello"); //expected-error {{no matching member function for call to 'foo'}}
103 b
.bar(0); //expected-error {{no matching member function for call to 'bar'}}
105 a
.baz(b
); //expected-error {{no matching member function for call to 'baz'}}
107 a
.rab(); //expected-error {{no matching member function for call to 'rab'}}
108 a
.zab(3, 4, 5); //expected-error {{no matching member function for call to 'zab'}}
110 a
.ref(); // expected-error {{no matching member function for call to 'ref'}}
111 A().ref(1); // expected-error {{no matching member function for call to 'ref'}}
117 int f(); // expected-note {{'this' argument has type 'const S', but method is not marked const}}
118 void f(int); // expected-note {{requires 1 argument, but 0 were provided}}
121 int k
= p
->f(); // expected-error {{no matching member function for call to 'f'}}
124 void member_call_op_template(int *p
) {
125 // Ensure that we don't get confused about relative parameter / argument
127 [](int, int, auto...){}(p
, p
); // expected-error {{no matching function}} expected-note {{no known conversion}}