1 /* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 1996-2020 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18 /* Useful abreviations. */ 19 typedef void t; 20 typedef char tc; 21 typedef short ts; 22 typedef int ti; 23 typedef long tl; 24 typedef long long tll; 25 typedef float tf; 26 typedef double td; 27 typedef long double tld; 28 29 /* Force the type of each field. */ 30 #ifndef tA 31 typedef t tA; 32 #endif 33 #ifndef tB 34 typedef tA tB; 35 #endif 36 #ifndef tC 37 typedef tB tC; 38 #endif 39 #ifndef tD 40 typedef tC tD; 41 #endif 42 #ifndef tE 43 typedef tD tE; 44 #endif 45 #ifndef tF 46 typedef tE tF; 47 #endif 48 #ifndef tG 49 typedef tF tG; 50 #endif 51 #ifndef tH 52 typedef tG tH; 53 #endif 54 #ifndef tI 55 typedef tH tI; 56 #endif 57 #ifndef tJ 58 typedef tI tJ; 59 #endif 60 #ifndef tK 61 typedef tJ tK; 62 #endif 63 #ifndef tL 64 typedef tK tL; 65 #endif 66 #ifndef tM 67 typedef tL tM; 68 #endif 69 #ifndef tN 70 typedef tM tN; 71 #endif 72 #ifndef tO 73 typedef tN tO; 74 #endif 75 #ifndef tP 76 typedef tO tP; 77 #endif 78 #ifndef tQ 79 typedef tP tQ; 80 #endif 81 #ifndef tR 82 typedef tQ tR; 83 #endif 84 85 struct struct1 {tA a;}; 86 struct struct2 {tA a; tB b;}; 87 struct struct3 {tA a; tB b; tC c; }; 88 struct struct4 {tA a; tB b; tC c; tD d; }; 89 struct struct5 {tA a; tB b; tC c; tD d; tE e; }; 90 struct struct6 {tA a; tB b; tC c; tD d; tE e; tF f; }; 91 struct struct7 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; }; 92 struct struct8 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; }; 93 struct struct9 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; }; 94 struct struct10 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; }; 95 struct struct11 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; }; 96 struct struct12 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; }; 97 struct struct13 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; }; 98 struct struct14 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; }; 99 struct struct15 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; }; 100 struct struct16 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; }; 101 struct struct17 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; }; 102 struct struct18 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; tR r; }; 103 104 struct struct1 foo1 = {'1'}, L1; 105 struct struct2 foo2 = {'a','2'}, L2; 106 struct struct3 foo3 = {'1','b','3'}, L3; 107 struct struct4 foo4 = {'a','2','c','4'}, L4; 108 struct struct5 foo5 = {'1','b','3','d','5'}, L5; 109 struct struct6 foo6 = {'a','2','c','4','e','6'}, L6; 110 struct struct7 foo7 = {'1','b','3','d','5','f','7'}, L7; 111 struct struct8 foo8 = {'a','2','c','4','e','6','g','8'}, L8; 112 struct struct9 foo9 = {'1','b','3','d','5','f','7','h','9'}, L9; 113 struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10; 114 struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11; 115 struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12; 116 struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13; 117 struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14; 118 struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15; 119 struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16; 120 struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17; 121 struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G','q','I'}, L18; 122 123 struct struct1 fun1() 124 { 125 return foo1; 126 } 127 struct struct2 fun2() 128 { 129 return foo2; 130 } 131 struct struct3 fun3() 132 { 133 return foo3; 134 } 135 struct struct4 fun4() 136 { 137 return foo4; 138 } 139 struct struct5 fun5() 140 { 141 return foo5; 142 } 143 struct struct6 fun6() 144 { 145 return foo6; 146 } 147 struct struct7 fun7() 148 { 149 return foo7; 150 } 151 struct struct8 fun8() 152 { 153 return foo8; 154 } 155 struct struct9 fun9() 156 { 157 return foo9; 158 } 159 struct struct10 fun10() 160 { 161 return foo10; 162 } 163 struct struct11 fun11() 164 { 165 return foo11; 166 } 167 struct struct12 fun12() 168 { 169 return foo12; 170 } 171 struct struct13 fun13() 172 { 173 return foo13; 174 } 175 struct struct14 fun14() 176 { 177 return foo14; 178 } 179 struct struct15 fun15() 180 { 181 return foo15; 182 } 183 struct struct16 fun16() 184 { 185 return foo16; 186 } 187 struct struct17 fun17() 188 { 189 return foo17; 190 } 191 struct struct18 fun18() 192 { 193 return foo18; 194 } 195 196 void Fun1(struct struct1 foo1) 197 { 198 L1 = foo1; 199 } 200 void Fun2(struct struct2 foo2) 201 { 202 L2 = foo2; 203 } 204 void Fun3(struct struct3 foo3) 205 { 206 L3 = foo3; 207 } 208 void Fun4(struct struct4 foo4) 209 { 210 L4 = foo4; 211 } 212 void Fun5(struct struct5 foo5) 213 { 214 L5 = foo5; 215 } 216 void Fun6(struct struct6 foo6) 217 { 218 L6 = foo6; 219 } 220 void Fun7(struct struct7 foo7) 221 { 222 L7 = foo7; 223 } 224 void Fun8(struct struct8 foo8) 225 { 226 L8 = foo8; 227 } 228 void Fun9(struct struct9 foo9) 229 { 230 L9 = foo9; 231 } 232 void Fun10(struct struct10 foo10) 233 { 234 L10 = foo10; 235 } 236 void Fun11(struct struct11 foo11) 237 { 238 L11 = foo11; 239 } 240 void Fun12(struct struct12 foo12) 241 { 242 L12 = foo12; 243 } 244 void Fun13(struct struct13 foo13) 245 { 246 L13 = foo13; 247 } 248 void Fun14(struct struct14 foo14) 249 { 250 L14 = foo14; 251 } 252 void Fun15(struct struct15 foo15) 253 { 254 L15 = foo15; 255 } 256 void Fun16(struct struct16 foo16) 257 { 258 L16 = foo16; 259 } 260 void Fun17(struct struct17 foo17) 261 { 262 L17 = foo17; 263 } 264 void Fun18(struct struct18 foo18) 265 { 266 L18 = foo18; 267 } 268 269 void 270 zed () 271 { 272 273 L1.a = L2.a = L3.a = L4.a = L5.a = L6.a = L7.a = L8.a = L9.a = L10.a = L11.a = L12.a = L13.a = L14.a = L15.a = L16.a = L17.a = L18.a = 'Z'; 274 275 L2.b = L3.b = L4.b = L5.b = L6.b = L7.b = L8.b = L9.b = L10.b = L11.b = L12.b = L13.b = L14.b = L15.b = L16.b = L17.b = L18.b = 'Z'; 276 277 L3.c = L4.c = L5.c = L6.c = L7.c = L8.c = L9.c = L10.c = L11.c = L12.c = L13.c = L14.c = L15.c = L16.c = L17.c = L18.c = 'Z'; 278 279 L4.d = L5.d = L6.d = L7.d = L8.d = L9.d = L10.d = L11.d = L12.d = L13.d = L14.d = L15.d = L16.d = L17.d = L18.d = 'Z'; 280 281 L5.e = L6.e = L7.e = L8.e = L9.e = L10.e = L11.e = L12.e = L13.e = L14.e = L15.e = L16.e = L17.e = L18.e = 'Z'; 282 283 L6.f = L7.f = L8.f = L9.f = L10.f = L11.f = L12.f = L13.f = L14.f = L15.f = L16.f = L17.f = L18.f = 'Z'; 284 285 L7.g = L8.g = L9.g = L10.g = L11.g = L12.g = L13.g = L14.g = L15.g = L16.g = L17.g = L18.g = 'Z'; 286 287 L8.h = L9.h = L10.h = L11.h = L12.h = L13.h = L14.h = L15.h = L16.h = L17.h = L18.h = 'Z'; 288 289 L9.i = L10.i = L11.i = L12.i = L13.i = L14.i = L15.i = L16.i = L17.i = L18.i = 'Z'; 290 291 L10.j = L11.j = L12.j = L13.j = L14.j = L15.j = L16.j = L17.j = L18.j = 'Z'; 292 293 L11.k = L12.k = L13.k = L14.k = L15.k = L16.k = L17.k = L18.k = 'Z'; 294 295 L12.l = L13.l = L14.l = L15.l = L16.l = L17.l = L18.l = 'Z'; 296 297 L13.m = L14.m = L15.m = L16.m = L17.m = L18.m = 'Z'; 298 299 L14.n = L15.n = L16.n = L17.n = L18.n = 'Z'; 300 301 L15.o = L16.o = L17.o = L18.o = 'Z'; 302 303 L16.p = L17.p = L18.p = 'Z'; 304 305 L17.q = L18.q = 'Z'; 306 307 L18.r = 'Z'; 308 } 309 310 static struct { char c; } chartest[256]; 311 312 int main() 313 { 314 int i; 315 316 for (i = 0; i < 256; i++) 317 chartest[i].c = i; 318 chartest[0].c = 0; /* chartest-done */ 319 320 Fun1(foo1); 321 Fun2(foo2); 322 Fun3(foo3); 323 Fun4(foo4); 324 Fun5(foo5); 325 Fun6(foo6); 326 Fun7(foo7); 327 Fun8(foo8); 328 Fun9(foo9); 329 Fun10(foo10); 330 Fun11(foo11); 331 Fun12(foo12); 332 Fun13(foo13); 333 Fun14(foo14); 334 Fun15(foo15); 335 Fun16(foo16); 336 Fun17(foo17); 337 Fun18(foo18); 338 339 /* An (almost-)infinite loop that first clears all the variables and then 340 calls each function. This "hack" is to make testing random 341 functions easier - "advance funN" is guaranteed to have always 342 been preceded by a global variable clearing zed call. 343 We don't let this run forever in case gdb crashes while testing, 344 we don't want to be left eating all cpu on the user's system. */ 345 346 for (i = 0; i < 1000000; ++i) 347 { 348 zed (); 349 L1 = fun1(); 350 L2 = fun2(); 351 L3 = fun3(); 352 L4 = fun4(); 353 L5 = fun5(); 354 L6 = fun6(); 355 L7 = fun7(); 356 L8 = fun8(); 357 L9 = fun9(); 358 L10 = fun10(); 359 L11 = fun11(); 360 L12 = fun12(); 361 L13 = fun13(); 362 L14 = fun14(); 363 L15 = fun15(); 364 L16 = fun16(); 365 L17 = fun17(); 366 L18 = fun18(); 367 } 368 369 return 0; 370 } 371