2 !!DESCRIPTION!! C-Manual Chapter 8.1: storage class specifiers
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_IMPLICIT_FUNC_PROTOTYPES
52 #ifndef NO_OLD_FUNC_DECL
53 s81(pd0) /* 8.1 Storage Class Specifiers */
56 int s81(struct defs *pd0)
59 static char s81er[] = "s81,er%d\n";
60 static char qs81[8] = "s81 ";
62 int k, rc, j, crc, prc, irc;
69 static char badtest[] = "Register count for %s is unreliable.\n";
70 static char goodtest[] = "%d registers assigned to %s variables.\n";
81 /* The storage class specifiers are:
89 The first three of these were treated earlier, in s4. The last
90 will be checked in s88. "Register" remains.
92 There are three flavors of register, viz., char, int and pointer.
93 We wish first to ascertain that the representations as register
94 are consistent with the corresponding nonregister representations.
106 if ( rchar != nrchar ) crc = 1;
107 if ( rptr != nrptr ) prc = 1;
108 if ( rint != nrint ) irc = 1;
114 if( pd0 -> flgd != 0 ) printf(s81er,1);
119 if( pd0 -> flgd != 0 ) printf(s81er,2);
124 if( pd0 -> flgd != 0 ) printf(s81er,4);
127 /* Now we check to see if variables are actually being assigned
131 if ( pd0->flgm != 0 ) {
132 if ( k < 0 ) printf(badtest,"char");
133 else printf(goodtest,k,"char");
137 if ( pd0->flgm != 0 ) {
138 if ( k<0 ) printf(badtest,"pointer");
139 else printf(goodtest,k,"pointer");
143 if ( pd0->flgm != 0 ) {
144 if ( k<0 ) printf(badtest,"int");
145 else printf(goodtest,k,"int");
150 regc() { /* char to register assignment */
151 /* Testing a variable whose storage class has been spec-
152 ified as "register" is somewhat tricky, but it can be done in a
153 fairly reliable fashion by taking advantage of our knowledge of the
154 ways in which compilers operate. If we declare a collection of vari-
155 ables of the same storage class, we would expect that, when storage
156 for these variables is actually allocated, the variables will be
157 bunched together and ordered according to one of the following
160 (a) the order in which they were defined.
161 (b) the order in which they are used.
163 (d) the order in which they appear in the compiler's
167 Hence, if we define a sequence of variables in close alpha-
168 betical order, and use them in the same order in which we define
169 them, we would expect the differences between the addresses of
170 successive variables to be constant, except in case (d) where the
171 symbol table is a hash table, or in case (e). If a subsequence in
172 the middle of this sequence is selected, and for this subsequence,
173 every other variable is specified to be "register", and address
174 differences are taken between adjacent nonregister variables, we would
175 still expect to find constant differences if the "register" vari-
176 ables were actually assigned to registers, and some other diff-
177 erences if they were not. Specifically, if we had N variables
178 specified as "register" of which the first n were actually ass-
179 igned to registers, we would expect the sequence of differences
180 to consist of a number of occurrences of some number, followed by
181 N-n occurrences of some other number, followed by several occurr-
182 ences of the first number. If we get a sequence like this, we can
183 determine, by simple subtraction, how many (if any) variables are
184 being assigned to registers. If we get some other sequence, we know
185 that the test is invalid. */
227 int s, n1, n2, nr, j, d[22];
291 /* The following FSM analyzes the string of differences. It accepts
292 strings of the form a+b+a+ and returns 16 minus the number of bs,
293 which is the number of variables that actually got into registers.
294 Otherwise it signals rejection by returning -1., indicating that the
295 test is unreliable. */
302 case 1: if (d[j] != n1) {
308 case 2: if (d[j] == n1) {
318 case 3: if (d[j] != n1) s = 4;
323 if (s == 3) return 16-nr;
326 regi() { /* int to register assignment */
327 /* Testing a variable whose storage class has been spec-
328 ified as "register" is somewhat tricky, but it can be done in a
329 fairly reliable fashion by taking advantage of our knowledge of the
330 ways in which compilers operate. If we declare a collection of vari-
331 ables of the same storage class, we would expect that, when storage
332 for these variables is actually allocated, the variables will be
333 bunched together and ordered according to one of the following
336 (a) the order in which they were defined.
337 (b) the order in which they are used.
339 (d) the order in which they appear in the compiler's
343 Hence, if we define a sequence of variables in close alpha-
344 betical order, and use them in the same order in which we define
345 them, we would expect the differences between the addresses of
346 successive variables to be constant, except in case (d) where the
347 symbol table is a hash table, or in case (e). If a subsequence in
348 the middle of this sequence is selected, and for this subsequence,
349 every other variable is specified to be "register", and address
350 differences are taken between adjacent nonregister variables, we would
351 still expect to find constant differences if the "register" vari-
352 ables were actually assigned to registers, and some other diff-
353 erences if they were not. Specifically, if we had N variables
354 specified as "register" of which the first n were actually ass-
355 igned to registers, we would expect the sequence of differences
356 to consist of a number of occurrences of some number, followed by
357 N-n occurrences of some other number, followed by several occurr-
358 ences of the first number. If we get a sequence like this, we can
359 determine, by simple subtraction, how many (if any) variables are
360 being assigned to registers. If we get some other sequence, we know
361 that the test is invalid. */
403 int s, n1, n2, nr, j, d[22];
468 /* The following FSM analyzes the string of differences. It accepts
469 strings of the form a+b+a+ and returns 16 minus the number of bs,
470 which is the number of variables that actually got into registers.
471 Otherwise it signals rejection by returning -1., indicating that the
472 test is unreliable. */
479 case 1: if (d[j] != n1) {
485 case 2: if (d[j] == n1) {
495 case 3: if (d[j] != n1) s = 4;
500 if (s == 3) return 16-nr;
503 regp() { /* pointer to register assignment */
504 /* Testing a variable whose storage class has been spec-
505 ified as "register" is somewhat tricky, but it can be done in a
506 fairly reliable fashion by taking advantage of our knowledge of the
507 ways in which compilers operate. If we declare a collection of vari-
508 ables of the same storage class, we would expect that, when storage
509 for these variables is actually allocated, the variables will be
510 bunched together and ordered according to one of the following
513 (a) the order in which they were defined.
514 (b) the order in which they are used.
516 (d) the order in which they appear in the compiler's
520 Hence, if we define a sequence of variables in close alpha-
521 betical order, and use them in the same order in which we define
522 them, we would expect the differences between the addresses of
523 successive variables to be constant, except in case (d) where the
524 symbol table is a hash table, or in case (e). If a subsequence in
525 the middle of this sequence is selected, and for this subsequence,
526 every other variable is specified to be "register", and address
527 differences are taken between adjacent nonregister variables, we would
528 still expect to find constant differences if the "register" vari-
529 ables were actually assigned to registers, and some other diff-
530 erences if they were not. Specifically, if we had N variables
531 specified as "register" of which the first n were actually ass-
532 igned to registers, we would expect the sequence of differences
533 to consist of a number of occurrences of some number, followed by
534 N-n occurrences of some other number, followed by several occurr-
535 ences of the first number. If we get a sequence like this, we can
536 determine, by simple subtraction, how many (if any) variables are
537 being assigned to registers. If we get some other sequence, we know
538 that the test is invalid. */
580 int s, n1, n2, nr, j, d[22];
645 /* The following FSM analyzes the string of differences. It accepts
646 strings of the form a+b+a+ and returns 16 minus the number of bs,
647 which is the number of variables that actually got into registers.
648 Otherwise it signals rejection by returning -1., indicating that the
649 test is unreliable. */
655 case 1: if (d[j] != n1) {
661 case 2: if (d[j] == n1) {
671 case 3: if (d[j] != n1) s = 4;
676 if (s == 3) return 16-nr;
680 /*********************************************************************************************
681 the main loop that launches the sections
682 *********************************************************************************************/
684 #ifndef NO_TYPELESS_STRUCT_PTR
685 int section(int j,struct* pd0){
687 int section(int j,void* pd0){
690 case 0: return s81(pd0);
694 #define cq_sections 1
697 C REFERENCE MANUAL (main)
700 #ifndef NO_OLD_FUNC_DECL
706 int main(int n,char **args) {
710 static struct defs d0, *pd0;
712 d0.flgs = 1; /* These flags dictate */
713 d0.flgm = 1; /* the verbosity of */
714 d0.flgd = 1; /* the program. */
719 for (j=0; j<cq_sections; j++) {
720 d0.rrc=section(j,pd0);
721 d0.crc=d0.crc+d0.rrc;
722 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
725 if(d0.crc == 0) printf("\nNo errors detected.\n");
726 else printf("\nFailed.\n");