blob: aabe8dde1b1ee75e40bd7505af2a40a1df2d1ab7 [file] [log] [blame]
Douglas Gregor70d26122008-11-12 17:17:38 +00001// RUN: clang -fsyntax-only -verify %s
2struct yes;
3struct no;
4
5struct Short {
6 operator short();
7};
8
9struct Long {
10 operator long();
11};
12
13yes& islong(long);
14no& islong(int);
15
16void f(Short s, Long l) {
17 // C++ [over.built]p12
18 (void)static_cast<yes&>(islong(s + l));
19 (void)static_cast<no&>(islong(s + s));
20
21 // C++ [over.built]p17
22 (void)static_cast<yes&>(islong(s % l));
23 (void)static_cast<yes&>(islong(l << s));
24 (void)static_cast<no&>(islong(s << l));
25}
26
27struct ShortRef {
28 operator short&();
29};
30
31struct LongRef {
32 operator volatile long&();
33};
34
35void g(ShortRef sr, LongRef lr) {
36 // C++ [over.built]p18
37 short& sr1 = (sr *= lr);
38 volatile long& lr1 = (lr *= sr);
39
40 // C++ [over.built]p22
41 short& sr2 = (sr %= lr);
42 volatile long& lr2 = (lr <<= sr);
43
44 bool b1 = (sr && lr) || (sr || lr);
45}
46
47struct VolatileIntPtr {
48 operator int volatile *();
49};
50
51struct ConstIntPtr {
52 operator int const *();
53};
54
55void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip, ShortRef sr) {
56#if 0
57 // FIXME: Enable these tests once we have operator overloading for
58 // operator[].
59 const int& cir1 = cip[sr];
60 const int& cir2 = sr[cip];
61 volatile int& vir1 = vip[sr];
62 volatile int& vir2 = sr[vip];
63#endif
64 bool b1 = (vip == cip);
65 long p1 = vip - cip;
66}