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
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_IMPLICIT_FUNC_PROTOTYPES
50 #ifndef NO_OLD_FUNC_DECL
51 s81(pd0) /* 8.1 Storage Class Specifiers */
54 int s81(struct defs *pd0)
57 static char s81er[] = "s81,er%d\n";
58 static char qs81[8] = "s81 ";
60 int k, rc, j, crc, prc, irc;
67 static char badtest[] = "Register count for %s is unreliable.\n";
68 static char goodtest[] = "%d registers assigned to %s variables.\n";
79 /* The storage class specifiers are:
87 The first three of these were treated earlier, in s4. The last
88 will be checked in s88. "Register" remains.
90 There are three flavors of register, viz., char, int and pointer.
91 We wish first to ascertain that the representations as register
92 are consistent with the corresponding nonregister representations.
104 if ( rchar != nrchar ) crc = 1;
105 if ( rptr != nrptr ) prc = 1;
106 if ( rint != nrint ) irc = 1;
112 if( pd0 -> flgd != 0 ) printf(s81er,1);
117 if( pd0 -> flgd != 0 ) printf(s81er,2);
122 if( pd0 -> flgd != 0 ) printf(s81er,4);
125 /* Now we check to see if variables are actually being assigned
129 if ( pd0->flgm != 0 ) {
130 if ( k < 0 ) printf(badtest,"char");
131 else printf(goodtest,k,"char");
135 if ( pd0->flgm != 0 ) {
136 if ( k<0 ) printf(badtest,"pointer");
137 else printf(goodtest,k,"pointer");
141 if ( pd0->flgm != 0 ) {
142 if ( k<0 ) printf(badtest,"int");
143 else printf(goodtest,k,"int");
148 regc() { /* char to register assignment */
149 /* Testing a variable whose storage class has been spec-
150 ified as "register" is somewhat tricky, but it can be done in a
151 fairly reliable fashion by taking advantage of our knowledge of the
152 ways in which compilers operate. If we declare a collection of vari-
153 ables of the same storage class, we would expect that, when storage
154 for these variables is actually allocated, the variables will be
155 bunched together and ordered according to one of the following
158 (a) the order in which they were defined.
159 (b) the order in which they are used.
161 (d) the order in which they appear in the compiler's
165 Hence, if we define a sequence of variables in close alpha-
166 betical order, and use them in the same order in which we define
167 them, we would expect the differences between the addresses of
168 successive variables to be constant, except in case (d) where the
169 symbol table is a hash table, or in case (e). If a subsequence in
170 the middle of this sequence is selected, and for this subsequence,
171 every other variable is specified to be "register", and address
172 differences are taken between adjacent nonregister variables, we would
173 still expect to find constant differences if the "register" vari-
174 ables were actually assigned to registers, and some other diff-
175 erences if they were not. Specifically, if we had N variables
176 specified as "register" of which the first n were actually ass-
177 igned to registers, we would expect the sequence of differences
178 to consist of a number of occurrences of some number, followed by
179 N-n occurrences of some other number, followed by several occurr-
180 ences of the first number. If we get a sequence like this, we can
181 determine, by simple subtraction, how many (if any) variables are
182 being assigned to registers. If we get some other sequence, we know
183 that the test is invalid. */
225 int s, n1, n2, nr, j, d[22];
289 /* The following FSM analyzes the string of differences. It accepts
290 strings of the form a+b+a+ and returns 16 minus the number of bs,
291 which is the number of variables that actually got into registers.
292 Otherwise it signals rejection by returning -1., indicating that the
293 test is unreliable. */
300 case 1: if (d[j] != n1) {
306 case 2: if (d[j] == n1) {
316 case 3: if (d[j] != n1) s = 4;
321 if (s == 3) return 16-nr;
324 regi() { /* int to register assignment */
325 /* Testing a variable whose storage class has been spec-
326 ified as "register" is somewhat tricky, but it can be done in a
327 fairly reliable fashion by taking advantage of our knowledge of the
328 ways in which compilers operate. If we declare a collection of vari-
329 ables of the same storage class, we would expect that, when storage
330 for these variables is actually allocated, the variables will be
331 bunched together and ordered according to one of the following
334 (a) the order in which they were defined.
335 (b) the order in which they are used.
337 (d) the order in which they appear in the compiler's
341 Hence, if we define a sequence of variables in close alpha-
342 betical order, and use them in the same order in which we define
343 them, we would expect the differences between the addresses of
344 successive variables to be constant, except in case (d) where the
345 symbol table is a hash table, or in case (e). If a subsequence in
346 the middle of this sequence is selected, and for this subsequence,
347 every other variable is specified to be "register", and address
348 differences are taken between adjacent nonregister variables, we would
349 still expect to find constant differences if the "register" vari-
350 ables were actually assigned to registers, and some other diff-
351 erences if they were not. Specifically, if we had N variables
352 specified as "register" of which the first n were actually ass-
353 igned to registers, we would expect the sequence of differences
354 to consist of a number of occurrences of some number, followed by
355 N-n occurrences of some other number, followed by several occurr-
356 ences of the first number. If we get a sequence like this, we can
357 determine, by simple subtraction, how many (if any) variables are
358 being assigned to registers. If we get some other sequence, we know
359 that the test is invalid. */
401 int s, n1, n2, nr, j, d[22];
466 /* The following FSM analyzes the string of differences. It accepts
467 strings of the form a+b+a+ and returns 16 minus the number of bs,
468 which is the number of variables that actually got into registers.
469 Otherwise it signals rejection by returning -1., indicating that the
470 test is unreliable. */
477 case 1: if (d[j] != n1) {
483 case 2: if (d[j] == n1) {
493 case 3: if (d[j] != n1) s = 4;
498 if (s == 3) return 16-nr;
501 regp() { /* pointer to register assignment */
502 /* Testing a variable whose storage class has been spec-
503 ified as "register" is somewhat tricky, but it can be done in a
504 fairly reliable fashion by taking advantage of our knowledge of the
505 ways in which compilers operate. If we declare a collection of vari-
506 ables of the same storage class, we would expect that, when storage
507 for these variables is actually allocated, the variables will be
508 bunched together and ordered according to one of the following
511 (a) the order in which they were defined.
512 (b) the order in which they are used.
514 (d) the order in which they appear in the compiler's
518 Hence, if we define a sequence of variables in close alpha-
519 betical order, and use them in the same order in which we define
520 them, we would expect the differences between the addresses of
521 successive variables to be constant, except in case (d) where the
522 symbol table is a hash table, or in case (e). If a subsequence in
523 the middle of this sequence is selected, and for this subsequence,
524 every other variable is specified to be "register", and address
525 differences are taken between adjacent nonregister variables, we would
526 still expect to find constant differences if the "register" vari-
527 ables were actually assigned to registers, and some other diff-
528 erences if they were not. Specifically, if we had N variables
529 specified as "register" of which the first n were actually ass-
530 igned to registers, we would expect the sequence of differences
531 to consist of a number of occurrences of some number, followed by
532 N-n occurrences of some other number, followed by several occurr-
533 ences of the first number. If we get a sequence like this, we can
534 determine, by simple subtraction, how many (if any) variables are
535 being assigned to registers. If we get some other sequence, we know
536 that the test is invalid. */
578 int s, n1, n2, nr, j, d[22];
643 /* The following FSM analyzes the string of differences. It accepts
644 strings of the form a+b+a+ and returns 16 minus the number of bs,
645 which is the number of variables that actually got into registers.
646 Otherwise it signals rejection by returning -1., indicating that the
647 test is unreliable. */
653 case 1: if (d[j] != n1) {
659 case 2: if (d[j] == n1) {
669 case 3: if (d[j] != n1) s = 4;
674 if (s == 3) return 16-nr;
678 /*********************************************************************************************
679 the main loop that launches the sections
680 *********************************************************************************************/
682 #ifndef NO_TYPELESS_STRUCT_PTR
683 int section(int j,struct* pd0){
685 int section(int j,void* pd0){
688 case 0: return s81(pd0);
692 #define cq_sections 1
695 C REFERENCE MANUAL (main)
698 #ifndef NO_OLD_FUNC_DECL
704 int main(int n,char **args) {
708 static struct defs d0, *pd0;
710 d0.flgs = 1; /* These flags dictate */
711 d0.flgm = 1; /* the verbosity of */
712 d0.flgd = 1; /* the program. */
717 for (j=0; j<cq_sections; j++) {
718 d0.rrc=section(j,pd0);
719 d0.crc=d0.crc+d0.rrc;
720 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
723 if(d0.crc == 0) printf("\nNo errors detected.\n");
724 else printf("\nFailed.\n");