2 !!DESCRIPTION!! C-Manual Chapter 8.6: Initialization
3 !!ORIGIN!! LCC 4.1 Testsuite
4 !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
10 int cbits; /* No. of bits per char */
12 int sbits; /* short */
14 int ubits; /* unsigned */
15 int fbits; /* float */
16 int dbits; /* double */
18 float fprec; /* Smallest number that can be */
19 float dprec; /* significantly added to 1. */
21 int flgs; /* Print return codes, by section */
22 int flgm; /* Announce machine dependencies */
23 int flgd; /* give explicit diagnostics */
24 int flgl; /* Report local return codes. */
25 int rrc; /* recent return code */
26 int crc; /* Cumulative return code */
27 char rfs[8]; /* Return from section */
31 int ubits; /* unsigned */
32 int fbits; /* float */
33 int dbits; /* double */
35 float fprec; /* Smallest number that can be */
36 float dprec; /* significantly added to 1. */
38 int flgs; /* Print return codes, by section */
39 int flgm; /* Announce machine dependencies */
40 int flgd; /* give explicit diagnostics */
41 int flgl; /* Report local return codes. */
42 int rrc; /* recent return code */
43 int crc; /* Cumulative return code */
44 char rfs[8]; /* Return from section */
46 #ifdef NO_LOCAL_PROTOTYPES
50 #ifndef NO_OLD_FUNC_DECL
51 s86(pd0) /* 8.6 Initialization */
55 int s86(struct defs *pd0){
57 static char s86er[] = "s86,er%d\n";
58 static char qs86[8] = "s86 ";
61 #ifndef NO_LOCAL_PROTOTYPES
65 static int x[] = {1,3,5};
66 static int *pint = x+2;
69 register int *rpint = apint+one();
72 static float y0[] = {1,3,5,2,4,6,3,5,7,0,0,0};
73 static float y1[4][3] = {
78 static float y2[4][3] = {1,3,5,2,4,6,3,5,7};
79 static float y3[4][3] = {
83 static signed y0[] = {1,3,5,2,4,6,3,5,7,0,0,0};
84 static signed y1[4][3] = {
89 #ifndef NO_SLOPPY_STRUCT_INIT
90 static signed y2[4][3] = {1,3,5,2,4,6,3,5,7};
92 static signed y2[4][3] = {{1,3,5},{2,4,6},{3,5,7}};
94 static signed y3[4][3] = {
102 while (*pt++ = *ps++);
104 /* The expression in an initializer for a static or
105 external variable must be a constant expression or
106 an expression that reduces to the address of a pre-
107 viously declared variable, possibly offset by a
112 if(pd0->flgd != 0) printf(s86er,1);
116 /* Automatic and register variables may be initialized
117 by arbitrary expressions involving constants and previously
118 declared variables and functions.
122 if(pd0->flgd != 0) printf(s86er,2);
127 if(pd0->flgd != 0) printf(s86er,4);
131 /* Static variables that are not initialized are guar-
132 anteed to start off as zero.
137 if(zero[j] != 0) lrc = 1;
139 if(pd0->flgd != 0) printf(s86er,8);
143 /* y0, y1, and y2, as declared, should define and
144 initialize identical arrays.
150 if( y1[i][j] != y2[i][j]
151 ||y1[i][j] != y0[k]) lrc = 1;
155 if(pd0->flgd != 0) printf(s86er,16);
159 /* y3 initializes the first column of the array and
160 leaves the rest zero.
164 for(j=0; j<4; j++) if(y3[j][0] != j+1) lrc = 1;
167 if(pd0->flgd != 0) printf(s86er,32);
172 #ifndef NO_OLD_FUNC_DECL
181 /*********************************************************************************************
182 the main loop that launches the sections
183 *********************************************************************************************/
185 #ifndef NO_TYPELESS_STRUCT_PTR
186 int section(int j,struct* pd0){
188 int section(int j,void* pd0){
191 case 0: return s86(pd0);
195 #define cq_sections 1
198 C REFERENCE MANUAL (main)
201 #ifndef NO_OLD_FUNC_DECL
207 int main(int n,char **args) {
211 static struct defs d0, *pd0;
213 d0.flgs = 1; /* These flags dictate */
214 d0.flgm = 1; /* the verbosity of */
215 d0.flgd = 1; /* the program. */
220 for (j=0; j<cq_sections; j++) {
221 d0.rrc=section(j,pd0);
222 d0.crc=d0.crc+d0.rrc;
223 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
226 if(d0.crc == 0) printf("\nNo errors detected.\n");
227 else printf("\nFailed.\n");