5 struct B
{ int dummy
= 2324; };
7 void *operator new(std::size_t size
) { void *p
= ::operator new(size
); side_effect
= 3; return p
; }
8 void *operator new[](std::size_t size
) { void *p
= ::operator new(size
); side_effect
= 4; return p
; }
9 void operator delete(void *p
) { std::free(p
); side_effect
= 1; }
10 void operator delete[](void *p
) { std::free(p
); side_effect
= 2; }
13 B
* operator->() { return &b
; }
14 int operator->*(int) { return 2; }
15 int operator+(int) { return 44; }
16 int operator+=(int) { return 42; }
17 int operator++(int) { return 123; }
18 int operator++() { return 1234; }
19 int operator-(int) { return 34; }
20 int operator-=(int) { return 32; }
21 int operator--() { return 321; }
22 int operator--(int) { return 4321; }
24 int operator*(int) { return 51; }
25 int operator*=(int) { return 52; }
26 int operator%(int) { return 53; }
27 int operator%=(int) { return 54; }
28 int operator/(int) { return 55; }
29 int operator/=(int) { return 56; }
30 int operator^(int) { return 57; }
31 int operator^=(int) { return 58; }
33 int operator|(int) { return 61; }
34 int operator|=(int) { return 62; }
35 int operator||(int) { return 63; }
36 int operator&(int) { return 64; }
37 int operator&=(int) { return 65; }
38 int operator&&(int) { return 66; }
40 int operator~() { return 71; }
41 int operator!() { return 72; }
42 int operator!=(int) { return 73; }
43 int operator=(int) { return 74; }
44 int operator==(int) { return 75; }
46 int operator<(int) { return 81; }
47 int operator<<(int) { return 82; }
48 int operator<=(int) { return 83; }
49 int operator<<=(int) { return 84; }
50 int operator>(int) { return 85; }
51 int operator>>(int) { return 86; }
52 int operator>=(int) { return 87; }
53 int operator>>=(int) { return 88; }
55 int operator,(int) { return 2012; }
56 int operator&() { return 2013; }
58 int operator()(int) { return 91; }
59 int operator[](int) { return 92; }
61 operator int() { return 11; }
62 operator long() { return 12; }
64 // Make sure this doesn't collide with
65 // the real operator int.
66 int operatorint() { return 13; }
67 int operatornew() { return 14; }
70 int main(int argc
, char **argv
) {
72 int result
= c
->dummy
;
120 result
+= static_cast<int>(c
);
121 result
+= static_cast<long>(c
);
122 result
+= c
.operatorint();
123 result
+= c
.operatornew();
128 //% self.expect("expr c->dummy", endstr=" 2324\n")
129 //% self.expect("expr c->*2", endstr=" 2\n")
130 //% self.expect("expr c + 44", endstr=" 44\n")
131 //% self.expect("expr c += 42", endstr=" 42\n")
132 //% self.expect("expr c++", endstr=" 123\n")
133 //% self.expect("expr ++c", endstr=" 1234\n")
134 //% self.expect("expr c - 34", endstr=" 34\n")
135 //% self.expect("expr c -= 32", endstr=" 32\n")
136 //% self.expect("expr c--", endstr=" 4321\n")
137 //% self.expect("expr --c", endstr=" 321\n")
138 //% self.expect("expr c * 3", endstr=" 51\n")
139 //% self.expect("expr c *= 3", endstr=" 52\n")
140 //% self.expect("expr c % 3", endstr=" 53\n")
141 //% self.expect("expr c %= 3", endstr=" 54\n")
142 //% self.expect("expr c / 3", endstr=" 55\n")
143 //% self.expect("expr c /= 3", endstr=" 56\n")
144 //% self.expect("expr c ^ 3", endstr=" 57\n")
145 //% self.expect("expr c ^= 3", endstr=" 58\n")
146 //% self.expect("expr c | 3", endstr=" 61\n")
147 //% self.expect("expr c |= 3", endstr=" 62\n")
148 //% self.expect("expr c || 3", endstr=" 63\n")
149 //% self.expect("expr c & 3", endstr=" 64\n")
150 //% self.expect("expr c &= 3", endstr=" 65\n")
151 //% self.expect("expr c && 3", endstr=" 66\n")
152 //% self.expect("expr ~c", endstr=" 71\n")
153 //% self.expect("expr !c", endstr=" 72\n")
154 //% self.expect("expr c!=1", endstr=" 73\n")
155 //% self.expect("expr c=1", endstr=" 74\n")
156 //% self.expect("expr c==1", endstr=" 75\n")
157 //% self.expect("expr c<1", endstr=" 81\n")
158 //% self.expect("expr c<<1", endstr=" 82\n")
159 //% self.expect("expr c<=1", endstr=" 83\n")
160 //% self.expect("expr c<<=1", endstr=" 84\n")
161 //% self.expect("expr c>1", endstr=" 85\n")
162 //% self.expect("expr c>>1", endstr=" 86\n")
163 //% self.expect("expr c>=1", endstr=" 87\n")
164 //% self.expect("expr c>>=1", endstr=" 88\n")
165 //% self.expect("expr c,1", endstr=" 2012\n")
166 //% self.expect("expr &c", endstr=" 2013\n")
167 //% self.expect("expr c(1)", endstr=" 91\n")
168 //% self.expect("expr c[1]", endstr=" 92\n")
169 //% self.expect("expr static_cast<int>(c)", endstr=" 11\n")
170 //% self.expect("expr static_cast<long>(c)", endstr=" 12\n")
171 //% self.expect("expr c.operatorint()", endstr=" 13\n")
172 //% self.expect("expr c.operatornew()", endstr=" 14\n")
173 //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
174 //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
175 //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
176 //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")