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
8 int cbits; /* No. of bits per char */
10 int sbits; /* short */
12 int ubits; /* unsigned */
13 int fbits; /* float */
14 int dbits; /* double */
16 float fprec; /* Smallest number that can be */
17 float dprec; /* significantly added to 1. */
19 int flgs; /* Print return codes, by section */
20 int flgm; /* Announce machine dependencies */
21 int flgd; /* give explicit diagnostics */
22 int flgl; /* Report local return codes. */
23 int rrc; /* recent return code */
24 int crc; /* Cumulative return code */
25 char rfs[8]; /* Return from section */
29 int ubits; /* unsigned */
30 int fbits; /* float */
31 int dbits; /* double */
33 float fprec; /* Smallest number that can be */
34 float dprec; /* significantly added to 1. */
36 int flgs; /* Print return codes, by section */
37 int flgm; /* Announce machine dependencies */
38 int flgd; /* give explicit diagnostics */
39 int flgl; /* Report local return codes. */
40 int rrc; /* recent return code */
41 int crc; /* Cumulative return code */
42 char rfs[8]; /* Return from section */
44 #ifdef NO_LOCAL_PROTOTYPES
48 #ifndef NO_OLD_FUNC_DECL
49 s86(pd0) /* 8.6 Initialization */
53 int s86(struct defs *pd0){
55 static char s86er[] = "s86,er%d\n";
56 static char qs86[8] = "s86 ";
59 #ifndef NO_LOCAL_PROTOTYPES
63 static int x[] = {1,3,5};
64 static int *pint = x+2;
67 register int *rpint = apint+one();
70 static float y0[] = {1,3,5,2,4,6,3,5,7,0,0,0};
71 static float y1[4][3] = {
76 static float y2[4][3] = {1,3,5,2,4,6,3,5,7};
77 static float y3[4][3] = {
81 static signed y0[] = {1,3,5,2,4,6,3,5,7,0,0,0};
82 static signed y1[4][3] = {
87 #ifndef NO_SLOPPY_STRUCT_INIT
88 static signed y2[4][3] = {1,3,5,2,4,6,3,5,7};
90 static signed y2[4][3] = {{1,3,5},{2,4,6},{3,5,7}};
92 static signed y3[4][3] = {
100 while (*pt++ = *ps++);
102 /* The expression in an initializer for a static or
103 external variable must be a constant expression or
104 an expression that reduces to the address of a pre-
105 viously declared variable, possibly offset by a
110 if(pd0->flgd != 0) printf(s86er,1);
114 /* Automatic and register variables may be initialized
115 by arbitrary expressions involving constants and previously
116 declared variables and functions.
120 if(pd0->flgd != 0) printf(s86er,2);
125 if(pd0->flgd != 0) printf(s86er,4);
129 /* Static variables that are not initialized are guar-
130 anteed to start off as zero.
135 if(zero[j] != 0) lrc = 1;
137 if(pd0->flgd != 0) printf(s86er,8);
141 /* y0, y1, and y2, as declared, should define and
142 initialize identical arrays.
148 if( y1[i][j] != y2[i][j]
149 ||y1[i][j] != y0[k]) lrc = 1;
153 if(pd0->flgd != 0) printf(s86er,16);
157 /* y3 initializes the first column of the array and
158 leaves the rest zero.
162 for(j=0; j<4; j++) if(y3[j][0] != j+1) lrc = 1;
165 if(pd0->flgd != 0) printf(s86er,32);
170 #ifndef NO_OLD_FUNC_DECL
179 /*********************************************************************************************
180 the main loop that launches the sections
181 *********************************************************************************************/
183 #ifndef NO_TYPELESS_STRUCT_PTR
184 int section(int j,struct* pd0){
186 int section(int j,void* pd0){
189 case 0: return s86(pd0);
193 #define cq_sections 1
196 C REFERENCE MANUAL (main)
199 #ifndef NO_OLD_FUNC_DECL
205 int main(int n,char **args) {
209 static struct defs d0, *pd0;
211 d0.flgs = 1; /* These flags dictate */
212 d0.flgm = 1; /* the verbosity of */
213 d0.flgd = 1; /* the program. */
218 for (j=0; j<cq_sections; j++) {
219 d0.rrc=section(j,pd0);
220 d0.crc=d0.crc+d0.rrc;
221 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
224 if(d0.crc == 0) printf("\nNo errors detected.\n");
225 else printf("\nFailed.\n");