1 // RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu %s
2 // RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++11 %s
31 typedef void (X::*pmf
)();
37 yes
& islong(unsigned long); // FIXME: shouldn't be needed
40 void f(Short s
, Long l
, Enum1 e1
, Enum2 e2
, Xpmf pmf
) {
45 // C++ [over.built]p10:
49 // C++ [over.built]p12
50 (void)static_cast<yes
&>(islong(s
+ l
));
51 (void)static_cast<no
&>(islong(s
+ s
));
53 // C++ [over.built]p16
57 // C++ [over.built]p17
58 (void)static_cast<yes
&>(islong(s
% l
));
59 (void)static_cast<yes
&>(islong(l
<< s
));
60 (void)static_cast<no
&>(islong(s
<< l
));
61 (void)static_cast<yes
&>(islong(e1
% l
));
62 // FIXME: should pass (void)static_cast<no&>(islong(e1 % e2));
69 struct ShortRef
{ // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
70 #if __cplusplus >= 201103L // C++11 or later
71 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
77 operator volatile long&();
84 struct XpmfRef
{ // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
85 #if __cplusplus >= 201103L // C++11 or later
86 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
95 void g(BoolRef br
, ShortRef sr
, LongRef lr
, FloatRef fr
, E2Ref e2_ref
, XpmfRef pmf_ref
) {
102 // C++ [over.built]p4
105 // C++ [over.built]p4
106 bool b2
= br
--; // expected-error{{cannot decrement value of type 'BoolRef'}}
108 // C++ [over.built]p18
109 short& sr1
= (sr
*= lr
);
110 volatile long& lr1
= (lr
*= sr
);
112 // C++ [over.built]p20:
116 pmf
&pmr
= (pmf_ref
= &X::f
); // expected-error{{no viable overloaded '='}}
120 // C++ [over.built]p22
121 short& sr2
= (sr
%= lr
);
122 volatile long& lr2
= (lr
<<= sr
);
124 bool b1
= (sr
&& lr
) || (sr
|| lr
);
127 struct VolatileIntPtr
{
128 operator int volatile *();
132 operator int const *();
135 struct VolatileIntPtrRef
{
136 operator int volatile *&();
139 struct ConstIntPtrRef
{
140 operator int const *&();
143 void test_with_ptrs(VolatileIntPtr vip
, ConstIntPtr cip
, ShortRef sr
,
144 VolatileIntPtrRef vipr
, ConstIntPtrRef cipr
) {
145 const int& cir1
= cip
[sr
];
146 const int& cir2
= sr
[cip
];
147 volatile int& vir1
= vip
[sr
];
148 volatile int& vir2
= sr
[vip
];
149 bool b1
= (vip
== cip
);
152 // C++ [over.built]p5:
153 int volatile *vip1
= vipr
++;
154 int const *cip1
= cipr
++;
155 int volatile *&vipr1
= ++vipr
;
156 int const *&cipr1
= --cipr
;
158 // C++ [over.built]p6:
159 int volatile &ivr
= *vip
;
161 // C++ [over.built]p8:
162 int volatile *vip2
= +vip
;
166 // C++ [over.built]p13:
167 int volatile &ivr2
= vip
[17];
168 int const &icr2
= 17[cip
];
171 // C++ [over.match.open]p4
173 void test_assign_restrictions(ShortRef
& sr
) {
174 sr
= (short)0; // expected-error{{no viable overloaded '='}}
178 struct Derived1
: Base
{ };
179 struct Derived2
: Base
{ };
182 struct ConvertibleToPtrOf
{
186 bool test_with_base_ptrs(ConvertibleToPtrOf
<Derived1
> d1
,
187 ConvertibleToPtrOf
<Derived2
> d2
) {
188 return d1
== d2
; // expected-error{{invalid operands}}
193 template< typename T
> operator T() const;
196 void test_dr425(A a
) {
197 (void)(1.0f
* a
); // expected-error{{ambiguous}} \
198 // expected-note 12{{candidate}}
204 const int a
[][2] = {{1}};
211 (void)__extension__(A());
215 typedef enum { Enum1
, Enum2
, Enum3
} MyEnum
;
217 template<typename X
> bool operator>(const X
&inX1
, const X
&inX2
);
228 operator const char *();
238 // FIXME: It would be nice to report fewer candidates here.
239 (void)(foo
- foo
); // expected-error{{use of overloaded operator '-' is ambiguous}} \
240 // expected-note 4{{built-in candidate operator-}} \
241 // expected-note{{142 candidates omitted}}
242 return foo
[zero
] == zero
;
248 operator const void *() const;
251 operator const unsigned *() const;
252 operator unsigned *();
271 operator int* __restrict
&();
274 void user_conversions(RestrictInt ri
) {
283 struct X
{ operator __int128() const; } x
;
284 bool a
= x
== __int128(0);
287 struct Y
{ operator unsigned __int128() const; } y
;
288 bool c
= y
== __int128(0);