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