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