1 // RUN: clang-cc -fsyntax-only -verify %s
22 bool operator-(Y
, Y
); // expected-note{{candidate function}}
23 bool operator-(Z
, Z
); // expected-note{{candidate function}}
27 bool b
= y
- z
; // expected-error{{use of overloaded operator '-' is ambiguous; candidates are:}}
31 bool operator==(Z
&); // expected-note{{candidate function}}
36 bool operator==(A
&, Z
&); // expected-note{{candidate function}}
38 void h(A a
, const A ac
, Z z
) {
40 a
== z
; // expected-error{{use of overloaded operator '==' is ambiguous; candidates are:}}
41 ac
== z
; // expected-error{{invalid operands to binary expression ('struct A const' and 'struct Z')}}
45 bool operator==(const B
&) const;
63 // C++ [over.match.oper]p3 - enum restriction.
64 float& operator==(E1
, E2
);
66 void enum_test(Enum1 enum1
, Enum2 enum2
, E1 e1
, E2 e2
) {
67 float &f1
= (e1
== e2
);
68 float &f2
= (enum1
== e2
);
69 float &f3
= (e1
== enum2
);
70 float &f4
= (enum1
== enum2
); // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a temporary of type 'bool'}}
75 PostInc
operator++(int);
76 PostInc
& operator++();
80 PostDec
operator--(int);
81 PostDec
& operator--();
84 void incdec_test(PostInc pi
, PostDec pd
) {
85 const PostInc
& pi1
= pi
++;
86 const PostDec
& pd1
= pd
--;
93 long& operator*() const volatile;
96 void test_smartptr(SmartPtr ptr
, const SmartPtr cptr
,
97 const volatile SmartPtr cvptr
) {
105 int& operator[](int);
108 void test_arraylike(ArrayLike a
) {
116 void test_smartref(SmartRef r
) {
120 bool& operator,(X
, Y
);
122 void test_comma(X x
, Y y
) {
128 int& operator()(int, double = 2.71828); // expected-note{{candidate function}}
129 float& operator()(int, double, long, ...); // expected-note{{candidate function}}
131 double& operator()(float); // expected-note{{candidate function}}
135 int& operator()(int i
= 0);
136 double& operator()(...) const;
139 void test_callable(Callable c
, Callable2 c2
, const Callable2
& c2c
) {
141 float &fr
= c(1, 3.14159, 17, 42);
143 c(); // expected-error{{no matching function for call to object of type 'struct Callable'; candidates are:}}
145 double &dr
= c(1.0f
);
154 typedef INTREF
Func1(FLOAT
, double);
155 typedef float& Func2(int, double);
157 struct ConvertToFunc
{
158 operator Func1
*(); // expected-note{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
159 operator Func2
&(); // expected-note{{conversion candidate of type 'float &(&)(int, double)'}}
163 void test_funcptr_call(ConvertToFunc ctf
) {
164 int &i1
= ctf(1.0f
, 2.0);
165 float &f2
= ctf((short int)1, 1.0f
);
166 ctf((long int)17, 2.0); // expected-error{{error: call to object of type 'struct ConvertToFunc' is ambiguous; candidates are:}}
175 HasMember
* operator->();
179 Arrow1
operator->(); // expected-note{{candidate function}}
182 void test_arrow(Arrow1 a1
, Arrow2 a2
, const Arrow2 a3
) {
185 a3
->m
; // expected-error{{no viable overloaded 'operator->'; candidate is}}
191 struct CopyCon
: public CopyConBase
{
192 CopyCon(const CopyConBase
&Base
);
194 CopyCon(const CopyConBase
*Base
) {
204 N::X
operator+(N::X
, N::X
);
208 void test_X(N::X x
) {