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 7typedef unsigned int udword; 8extern "C" { 9void __assert (const char *, int, const char *); 10} 11class ShZzy; 12class ShBe; 13class 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}; 42class 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); 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}; 60class ShBop 61{ 62 public: 63 inline ShBop(const ShBe* theBe); 64 void shWw(bool, 65 char* a1 = "", 66 char* a2 = "", 67 int a3 = -1, 68 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}; 88Sh::Sh(const char* theName, 89 const Xy& theXys) 90 :myXys(theXys), 91 myName(theName), 92 myParent(0) 93{} 94const char* 95Sh::name() const 96{ 97 return myName; 98} 99bool 100Sh::shXy(const Xy& theXy) 101{ 102 return myXys.sh(theXy); 103} 104ShZzy::ShZzy(const char* theName) 105 :Sh(theName, Xy(0)), 106 iAmInited(false) 107{} 108ShZzy::ShZzy(const char* theName, 109 const Xy& theXys) 110 :Sh(theName, theXys), 111 iAmInited(false) 112{} 113ShBop::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{} 123ShBop::bopType 124ShBop::bop() 125{ 126 ((!my2 || myBop == shFailed) ? (void)0 : __assert("foo", 91,"foo")); 127 return myBop; 128} 129int 130ShBop::numberOfVs() 131{ 132 return my2 + my1; 133} 134void 135ShBop::closeBop() 136{ 137 if (myBop == invalidBop) 138 { 139 myBop = shDone; 140 } 141} 142class ShBe; 143template <class ShCc> 144class ShAp : public ShZzy 145{ 146 public: 147 ShAp(const char* theName); 148 ShAp(const char* theName, 149 const Xy& theXys); 150 virtual ~ShAp() {} 151 typedef void (ShCc::*ShMethod)(); 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}; 162class 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}; 179template <class ShCc> 180ShAp<ShCc>::ShAp(const char* theName) 181 : ShZzy(theName), 182 myBop(0), 183 myBe(0) 184{} 185template <class ShCc> 186ShAp<ShCc>::ShAp(const char* theName, 187 const Sh::Xy& theXys) 188 : ShZzy(theName, theXys), 189 myBop(0), 190 myBe(0) 191{} 192template <class ShCc> 193ShBop* 194ShAp<ShCc>::bop() 195{ 196 ((myBop) ? (void)0 : __assert("foo", 96,"foo")); 197 return myBop; 198} 199class xSh : public ShAp<xSh> 200{ 201 public: 202 xSh(); 203 virtual ~xSh(); 204 void ap(); 205 void uff(); 206 void rtt(); 207}; 208class 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}; 227inline 228xUff::xUff() 229 : myUff(0) 230{ 231} 232inline 233xUff::xUff(udword theUff) 234 : myUff(theUff) 235{ 236} 237inline 238xUff::xUff( 239 const xUff& theUff) 240 : myUff(theUff.myUff) 241{ 242} 243inline xUff& 244xUff::operator = (const xUff& theUff) 245{ 246 myUff = theUff.myUff; 247 return *this; 248} 249inline xUff& 250xUff::operator = (udword theUff) 251{ 252 myUff = theUff; 253 return *this; 254} 255inline 256xUff::operator udword() const 257{ 258 return myUff; 259} 260inline bool 261xUff::operator < (const xUff ding) const 262{ 263 return (((int) (myUff - ding.myUff)) < 0); 264} 265inline bool 266xUff::operator <= (const xUff ding) const 267{ 268 return (((int) (myUff - ding.myUff)) <= 0); 269} 270inline bool 271xUff::operator > (const xUff ding) const 272{ 273 return (((int) (myUff - ding.myUff)) > 0); 274} 275inline bool 276xUff::operator >= (const xUff ding) const 277{ 278 return (((int) (myUff - ding.myUff)) >= 0); 279} 280inline bool 281xUff::operator == (const xUff ding) const 282{ 283 return (myUff == ding.myUff); 284} 285inline 286xUff::xUff(unsigned char* theUff) 287{ 288 myUff = *(udword *)theUff; 289} 290void 291xSh::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