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
9 /*include "cq26.c"*/ /* hardware check */
12 int cbits; /* No. of bits per char */
14 int sbits; /* short */
16 int ubits; /* unsigned */
17 int fbits; /* float */
18 int dbits; /* double */
20 float fprec; /* Smallest number that can be */
21 float dprec; /* significantly added to 1. */
23 int flgs; /* Print return codes, by section */
24 int flgm; /* Announce machine dependencies */
25 int flgd; /* give explicit diagnostics */
26 int flgl; /* Report local return codes. */
27 int rrc; /* recent return code */
28 int crc; /* Cumulative return code */
29 char rfs[8]; /* Return from section */
33 int ubits; /* unsigned */
34 int fbits; /* float */
35 int dbits; /* double */
37 float fprec; /* Smallest number that can be */
38 float dprec; /* significantly added to 1. */
40 int flgs; /* Print return codes, by section */
41 int flgm; /* Announce machine dependencies */
42 int flgd; /* give explicit diagnostics */
43 int flgl; /* Report local return codes. */
44 int rrc; /* recent return code */
45 int crc; /* Cumulative return code */
46 char rfs[8]; /* Return from section */
50 #ifndef NO_OLD_FUNC_DECL
51 s71(pd0) /* 7.1 Primary expressions */
55 int s71(struct defs *pd0){
57 static char s71er[] = "s71,er%d\n";
58 static char qs71[8] = "s71 ";
62 #ifndef NO_SLOPPY_EXTERN
63 int x[10], McCarthy(), clobber(), a, b, *p;
70 while (*pt++ = *ps++);
72 /* Testing of expressions and operators is quite complicated,
73 because (a) problems are apt to surface in queer combinations
74 of operators and operands, rather than in isolation,
75 and (b) the number of expressions needed to provoke a case
76 of improper behaviour may be quite large. Hence, we take the
77 following approach: for this section, and for subsequent
78 sections through 7.15, we will check the primitive operations
79 in isolation, thus verifying that the primitives work,
80 after a fashion. The job of testing combinations, we will
81 leave to a separate, machine-generated program, to be included
82 in the C test package at some later date.
85 /* A string is a primary expression. The identifier points to
86 the first character of a string.
91 if(pd0->flgd != 0) printf(s71er,1);
93 /* A parenthesized expression is a primary expression whose
94 type and value are the same as those of the unadorned
99 if(pd0->flgd != 0) printf(s71er,2);
102 /* A primary expression followed by an expression in square
103 brackets is a primary expression. The intuitive meaning is
104 that of a subscript. The expression E1[E2] is identical
105 (by definition) to *((E1)+(E2)).
109 if(x[5] != 1942 || x[5] != *((x)+(5))){
111 if(pd0->flgd != 0) printf(s71er,4);
114 /* If the various flavors of function calls didn't work, we
115 would never have gotten this far; however, we do need to
116 show that functions can be recursive...
119 if ( McCarthy(-5) != 91){
121 if(pd0->flgd != 0) printf(s71er,8);
124 /* and that argument passing is strictly by value. */
132 if(a != 2 || b != 2){
134 if(pd0->flgd != 0) printf(s71er,16);
137 /* Finally, structures and unions are addressed thusly: */
141 if(pd0->dprec != (*pd0).dprec){
143 if(pd0->flgd != 0) printf(s71er,32);
150 #ifndef NO_OLD_FUNC_DECL
157 if(x>100) return x-10;
158 else return McCarthy( McCarthy(x+11));
161 #ifndef NO_OLD_FUNC_DECL
165 int clobber(int x,int *y)
169 #ifndef NO_OLD_FUNC_DECL
172 #ifdef NO_TYPELESS_INT_PTR
179 #ifdef NO_TYPELESS_INT_PTR
192 /*********************************************************************************************
193 the main loop that launches the sections
194 *********************************************************************************************/
196 #ifndef NO_TYPELESS_STRUCT_PTR
197 int section(int j,struct* pd0){
199 int section(int j,void* pd0){
202 /*case 0: return s26(pd0);*/
203 case 0: return s71(pd0);
207 #define cq_sections 1
210 C REFERENCE MANUAL (main)
213 #ifndef NO_OLD_FUNC_DECL
219 int main(int n,char **args) {
223 static struct defs d0, *pd0;
225 d0.flgs = 1; /* These flags dictate */
226 d0.flgm = 1; /* the verbosity of */
227 d0.flgd = 1; /* the program. */
232 for (j=0; j<cq_sections; j++) {
233 d0.rrc=section(j,pd0);
234 d0.crc=d0.crc+d0.rrc;
235 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
238 if(d0.crc == 0) printf("\nNo errors detected.\n");
239 else printf("\nFailed.\n");