struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr33870-1.c
blob4234b50cdef22ae6124beecc5f674614c29d45a8
1 /*
2 pr33870-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #include <string.h>
13 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined (__SDCC_pdk15) // Lack of memory
14 typedef struct PgHdr PgHdr;
15 typedef unsigned char u8;
16 struct PgHdr {
17 int y;
18 struct {
19 unsigned int pgno;
20 PgHdr *pNextHash, *pPrevHash;
21 PgHdr *pNextFree, *pPrevFree;
22 PgHdr *pNextAll;
23 u8 inJournal;
24 short int nRef;
25 PgHdr *pDirty, *pPrevDirty;
26 unsigned int notUsed;
27 } x;
29 PgHdr **xx;
30 volatile int vx;
31 static inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)
33 PgHdr result;
34 PgHdr *pTail;
35 xx = &result.x.pDirty;
36 pTail = &result;
37 while( pA && pB ){
38 if( pA->x.pgno<pB->x.pgno ){
39 pTail->x.pDirty = pA;
40 pTail = pA;
41 pA = pA->x.pDirty;
42 }else{
43 pTail->x.pDirty = pB;
44 pTail = pB;
45 pB = pB->x.pDirty;
47 vx = (*xx)->y;
49 if( pA ){
50 pTail->x.pDirty = pA;
51 }else if( pB ){
52 pTail->x.pDirty = pB;
53 }else{
54 pTail->x.pDirty = 0;
56 return result.x.pDirty;
59 PgHdr *sort_pagelist(PgHdr *pIn)
61 PgHdr *a[25], *p;
62 int i;
63 memset (a, 0, sizeof (a));
64 while( pIn ){
65 p = pIn;
66 pIn = p->x.pDirty;
67 p->x.pDirty = 0;
68 for(i=0; i<25 -1; i++){
69 if( a[i]==0 ){
70 a[i] = p;
71 break;
72 }else{
73 p = merge_pagelist(a[i], p);
74 a[i] = 0;
75 a[i] = 0;
78 if( i==25 -1 ){
79 a[i] = merge_pagelist(a[i], p);
82 p = a[0];
83 for(i=1; i<25; i++){
84 p = merge_pagelist (p, a[i]);
86 return p;
88 #endif
90 void
91 testTortureExecute (void)
93 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined (__SDCC_pdk15) // Lack of memory
94 PgHdr a[5];
95 PgHdr *p;
96 a[0].x.pgno = 5;
97 a[0].x.pDirty = &a[1];
98 a[1].x.pgno = 4;
99 a[1].x.pDirty = &a[2];
100 a[2].x.pgno = 1;
101 a[2].x.pDirty = &a[3];
102 a[3].x.pgno = 3;
103 a[3].x.pDirty = 0;
104 p = sort_pagelist (&a[0]);
105 if (p->x.pDirty == p)
106 ASSERT (0);
107 return;
108 #endif