1 // { dg-do assemble }
2 // { dg-options "-O2 -g" }
3 // (Should preferrably cycle through options.)
4 // Origin: Hans-Peter Nilsson <hp@axis.com>
5 // See <URL:http://gcc.gnu.org/ml/gcc-patches/2000-06/msg00310.html>
6
7 typedef unsigned int udword;
8 extern "C" {
9 void __assert (const char *, int, const char *);
10 }
11 class ShZzy;
12 class ShBe;
13 class Sh
14 {
15 public:
16 class Xy;
17 inline Sh(const char* theName,
18 const Xy& theXys);
19 virtual ~Sh();
20 inline const char* name() const;
21 inline bool shXy(const Xy& theXy);
22 virtual void setParent(Sh* theParent);
23 class Xy
24 {
25 public:
26 Xy(int theXy);
27 Xy(const Xy& theXy);
28 Xy& operator = (const Xy&);
29 bool sh(const Xy& theXy);
30 private:
31 int myXyFlags;
32 };
33 protected:
34 Xy myXys;
35 private:
36 Sh();
37 Sh(const Sh&);
38 Sh& operator = (const Sh&);
39 const char* myName;
40 Sh* myParent;
41 };
42 class ShZzy : public Sh
43 {
44 public:
45 inline ShZzy(const char* theName);
46 inline ShZzy(const char* theName,
47 const Xy& theXys);
48 virtual ~ShZzy();
49 void addShTo(char* theParent);
ap()50 virtual void ap() {}
51 void addSh(Sh* theSh);
52 virtual void setParent(Sh* theParent);
53 void baseAp();
54 private:
55 ShZzy();
56 ShZzy(const ShZzy&);
57 ShZzy& operator = (const ShZzy&);
58 bool iAmInited;
59 };
60 class ShBop
61 {
62 public:
63 inline ShBop(const ShBe* theBe);
64 void shWw(bool,
65 const char* a1 = "",
66 const char* a2 = "",
67 int a3 = -1,
68 const char* a4 = "foo");
69 typedef enum { shOk,
70 shFailed,
71 shDone,
72 invalidBop } bopType;
73 inline bopType bop();
74 inline int numberOfVs();
75 inline void closeBop();
76 private:
77 ShBop(const ShBop&);
78 ShBop& operator = (const ShBop&);
79 const ShBe* myBe;
80 bopType myBop;
81 int my1;
82 int my2;
83 const char* my3;
84 const char* my4;
85 int my5;
86 const char* my6;
87 };
Sh(const char * theName,const Xy & theXys)88 Sh::Sh(const char* theName,
89 const Xy& theXys)
90 :myXys(theXys),
91 myName(theName),
92 myParent(0)
93 {}
94 const char*
name()95 Sh::name() const
96 {
97 return myName;
98 }
99 bool
shXy(const Xy & theXy)100 Sh::shXy(const Xy& theXy)
101 {
102 return myXys.sh(theXy);
103 }
ShZzy(const char * theName)104 ShZzy::ShZzy(const char* theName)
105 :Sh(theName, Xy(0)),
106 iAmInited(false)
107 {}
ShZzy(const char * theName,const Xy & theXys)108 ShZzy::ShZzy(const char* theName,
109 const Xy& theXys)
110 :Sh(theName, theXys),
111 iAmInited(false)
112 {}
ShBop(const ShBe * theBe)113 ShBop::ShBop(const ShBe* theBe)
114 :myBe(theBe),
115 myBop(invalidBop),
116 my1(0),
117 my2(0),
118 my3(""),
119 my4(""),
120 my5(0),
121 my6("")
122 {}
123 ShBop::bopType
bop()124 ShBop::bop()
125 {
126 ((!my2 || myBop == shFailed) ? (void)0 : __assert("foo", 91,"foo"));
127 return myBop;
128 }
129 int
numberOfVs()130 ShBop::numberOfVs()
131 {
132 return my2 + my1;
133 }
134 void
closeBop()135 ShBop::closeBop()
136 {
137 if (myBop == invalidBop)
138 {
139 myBop = shDone;
140 }
141 }
142 class ShBe;
143 template <class ShCc>
144 class ShAp : public ShZzy
145 {
146 public:
147 ShAp(const char* theName);
148 ShAp(const char* theName,
149 const Xy& theXys);
~ShAp()150 virtual ~ShAp() {}
151 typedef void (ShCc::*ShMethod)();
ap()152 virtual void ap() {}
153 protected:
154 ShBop* bop();
155 private:
156 ShAp();
157 ShAp(const ShAp&);
158 ShAp& operator = (const ShAp&);
159 ShBop* myBop;
160 ShBe* myBe;
161 };
162 class ShBe : public Sh
163 {
164 public:
165 inline ShBe(const char* theName);
166 inline ShBe(const char* theName,
167 const Xy& theXys);
168 inline virtual ~ShBe();
169 virtual void run() = 0;
170 ShBop* runBe();
171 protected:
172 inline ShBop* bop();
173 private:
174 ShBe();
175 ShBe(const ShBe&);
176 ShBe& operator = (const ShBe&);
177 ShBop* myBop;
178 };
179 template <class ShCc>
ShAp(const char * theName)180 ShAp<ShCc>::ShAp(const char* theName)
181 : ShZzy(theName),
182 myBop(0),
183 myBe(0)
184 {}
185 template <class ShCc>
ShAp(const char * theName,const Sh::Xy & theXys)186 ShAp<ShCc>::ShAp(const char* theName,
187 const Sh::Xy& theXys)
188 : ShZzy(theName, theXys),
189 myBop(0),
190 myBe(0)
191 {}
192 template <class ShCc>
193 ShBop*
bop()194 ShAp<ShCc>::bop()
195 {
196 ((myBop) ? (void)0 : __assert("foo", 96,"foo"));
197 return myBop;
198 }
199 class xSh : public ShAp<xSh>
200 {
201 public:
202 xSh();
203 virtual ~xSh();
204 void ap();
205 void uff();
206 void rtt();
207 };
208 class xUff
209 {
210 public:
211 xUff();
212 xUff(const xUff&);
213 xUff& operator = (const xUff&);
214 xUff(udword);
215 operator udword() const;
216 xUff& operator = (udword);
217 bool operator < (const xUff) const;
218 bool operator <= (const xUff) const;
219 bool operator > (const xUff) const;
220 bool operator >= (const xUff) const;
221 bool operator == (const xUff) const;
222 enum {size = 4};
223 xUff(unsigned char* theUff);
224 private:
225 udword myUff;
226 };
227 inline
xUff()228 xUff::xUff()
229 : myUff(0)
230 {
231 }
232 inline
xUff(udword theUff)233 xUff::xUff(udword theUff)
234 : myUff(theUff)
235 {
236 }
237 inline
xUff(const xUff & theUff)238 xUff::xUff(
239 const xUff& theUff)
240 : myUff(theUff.myUff)
241 {
242 }
243 inline xUff&
244 xUff::operator = (const xUff& theUff)
245 {
246 myUff = theUff.myUff;
247 return *this;
248 }
249 inline xUff&
250 xUff::operator = (udword theUff)
251 {
252 myUff = theUff;
253 return *this;
254 }
255 inline
udword()256 xUff::operator udword() const
257 {
258 return myUff;
259 }
260 inline bool
261 xUff::operator < (const xUff ding) const
262 {
263 return (((int) (myUff - ding.myUff)) < 0);
264 }
265 inline bool
266 xUff::operator <= (const xUff ding) const
267 {
268 return (((int) (myUff - ding.myUff)) <= 0);
269 }
270 inline bool
271 xUff::operator > (const xUff ding) const
272 {
273 return (((int) (myUff - ding.myUff)) > 0);
274 }
275 inline bool
276 xUff::operator >= (const xUff ding) const
277 {
278 return (((int) (myUff - ding.myUff)) >= 0);
279 }
280 inline bool
281 xUff::operator == (const xUff ding) const
282 {
283 return (myUff == ding.myUff);
284 }
285 inline
xUff(unsigned char * theUff)286 xUff::xUff(unsigned char* theUff)
287 {
288 myUff = *(udword *)theUff;
289 }
290 void
uff()291 xSh::uff()
292 {
293 static const udword halfudword = 0x80000000;
294 xUff aGah((udword)0);
295 udword diagonal = halfudword + (udword) aGah;
296 xUff aGeh(diagonal - 1);
297 xUff aGoh(diagonal + 1);
298 (bop()->shWw ((aGah.operator <=(aGah)), ("foo"), ( ""), 118, "foo"));
299 (bop()->shWw ((aGah.operator >=(aGah)), ("foo"), ( ""), 119, "foo"));
300 (bop()->shWw ((!(aGah.operator <(aGah))), ("foo"), ( ""), 120, "foo"));
301 (bop()->shWw ((!(aGah.operator >(aGah))), ("foo"), ( ""), 121, "foo"));
302 (bop()->shWw ((aGah.operator <(aGeh)), ("foo"), ( ""), 124, "foo"));
303 (bop()->shWw ((aGah.operator <=(aGeh)), ("foo"), ( ""), 125, "foo"));
304 (bop()->shWw ((!(aGah.operator >(aGeh))), ("foo"), ( ""), 126, "foo"));
305 (bop()->shWw ((!(aGah.operator >=(aGeh))), ("foo"), ( ""), 127, "foo"));
306 (bop()->shWw ((aGeh.operator >(aGah)), ("foo"), ( ""), 130, "foo"));
307 (bop()->shWw ((aGeh.operator >=(aGah)), ("foo"), ( ""), 131, "foo"));
308 (bop()->shWw ((!(aGeh.operator <(aGah))), ("foo"), ( ""), 132, "foo"));
309 (bop()->shWw ((!(aGeh.operator <=(aGah))), ("foo"), ( ""), 133, "foo"));
310 (bop()->shWw ((aGeh.operator <(aGoh)), ("foo"), ( ""), 136, "foo"));
311 (bop()->shWw ((aGeh.operator <=(aGoh)), ("foo"), ( ""), 137, "foo"));
312 (bop()->shWw ((!(aGeh.operator >(aGoh))), ("foo"), ( ""), 138, "foo"));
313 (bop()->shWw ((!(aGeh.operator >=(aGoh))), ("foo"), ( ""), 139, "foo"));
314 (bop()->shWw ((aGoh.operator >(aGeh)), ("foo"), ( ""), 142, "foo"));
315 (bop()->shWw ((aGoh.operator >=(aGeh)), ("foo"), ( ""), 143, "foo"));
316 (bop()->shWw ((!(aGoh.operator <(aGeh))), ("foo"), ( ""), 144, "foo"));
317 (bop()->shWw ((!(aGoh.operator <=(aGeh))), ("foo"), ( ""), 145, "foo"));
318 (bop()->shWw ((aGah.operator >(aGoh)), ("foo"), ( ""), 152, "foo"));
319 (bop()->shWw ((aGah.operator >=(aGoh)), ("foo"), ( ""), 153, "foo"));
320 (bop()->shWw ((!(aGah.operator <(aGoh))), ("foo"), ( ""), 154, "foo"));
321 (bop()->shWw ((!(aGah.operator <=(aGoh))), ("foo"), ( ""), 155, "foo"));
322 (bop()->shWw ((aGoh.operator <(aGah)), ("foo"), ( ""), 158, "foo"));
323 (bop()->shWw ((aGoh.operator <=(aGah)), ("foo"), ( ""), 159, "foo"));
324 (bop()->shWw ((!(aGoh.operator >(aGah))), ("foo"), ( ""), 160, "foo"));
325 (bop()->shWw ((!(aGoh.operator >=(aGah))), ("foo"), ( ""), 161, "foo"));
326 }
327