2 !!DESCRIPTION!! C-Manual Chapter 7.1: primary expressions
3 !!ORIGIN!! LCC 4.1 Testsuite
4 !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
7 /*include "cq26.c"*/ /* hardware check */
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 */
48 #ifndef NO_OLD_FUNC_DECL
49 s71(pd0) /* 7.1 Primary expressions */
53 int s71(struct defs *pd0){
55 static char s71er[] = "s71,er%d\n";
56 static char qs71[8] = "s71 ";
60 #ifndef NO_SLOPPY_EXTERN
61 int x[10], McCarthy(), clobber(), a, b, *p;
68 while (*pt++ = *ps++);
70 /* Testing of expressions and operators is quite complicated,
71 because (a) problems are apt to surface in queer combinations
72 of operators and operands, rather than in isolation,
73 and (b) the number of expressions needed to provoke a case
74 of improper behaviour may be quite large. Hence, we take the
75 following approach: for this section, and for subsequent
76 sections through 7.15, we will check the primitive operations
77 in isolation, thus verifying that the primitives work,
78 after a fashion. The job of testing combinations, we will
79 leave to a separate, machine-generated program, to be included
80 in the C test package at some later date.
83 /* A string is a primary expression. The identifier points to
84 the first character of a string.
89 if(pd0->flgd != 0) printf(s71er,1);
91 /* A parenthesized expression is a primary expression whose
92 type and value are the same as those of the unadorned
97 if(pd0->flgd != 0) printf(s71er,2);
100 /* A primary expression followed by an expression in square
101 brackets is a primary expression. The intuitive meaning is
102 that of a subscript. The expression E1[E2] is identical
103 (by definition) to *((E1)+(E2)).
107 if(x[5] != 1942 || x[5] != *((x)+(5))){
109 if(pd0->flgd != 0) printf(s71er,4);
112 /* If the various flavors of function calls didn't work, we
113 would never have gotten this far; however, we do need to
114 show that functions can be recursive...
117 if ( McCarthy(-5) != 91){
119 if(pd0->flgd != 0) printf(s71er,8);
122 /* and that argument passing is strictly by value. */
130 if(a != 2 || b != 2){
132 if(pd0->flgd != 0) printf(s71er,16);
135 /* Finally, structures and unions are addressed thusly: */
139 if(pd0->dprec != (*pd0).dprec){
141 if(pd0->flgd != 0) printf(s71er,32);
148 #ifndef NO_OLD_FUNC_DECL
155 if(x>100) return x-10;
156 else return McCarthy( McCarthy(x+11));
159 #ifndef NO_OLD_FUNC_DECL
163 int clobber(int x,int *y)
167 #ifndef NO_OLD_FUNC_DECL
170 #ifdef NO_TYPELESS_INT_PTR
177 #ifdef NO_TYPELESS_INT_PTR
190 /*********************************************************************************************
191 the main loop that launches the sections
192 *********************************************************************************************/
194 #ifndef NO_TYPELESS_STRUCT_PTR
195 int section(int j,struct* pd0){
197 int section(int j,void* pd0){
200 /*case 0: return s26(pd0);*/
201 case 0: return s71(pd0);
205 #define cq_sections 1
208 C REFERENCE MANUAL (main)
211 #ifndef NO_OLD_FUNC_DECL
217 int main(int n,char **args) {
221 static struct defs d0, *pd0;
223 d0.flgs = 1; /* These flags dictate */
224 d0.flgm = 1; /* the verbosity of */
225 d0.flgd = 1; /* the program. */
230 for (j=0; j<cq_sections; j++) {
231 d0.rrc=section(j,pd0);
232 d0.crc=d0.crc+d0.rrc;
233 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
236 if(d0.crc == 0) printf("\nNo errors detected.\n");
237 else printf("\nFailed.\n");