|
|
1.1 root 1: /* The Plum Hall Validation Suite for C
2: * Unpublished copyright (c) 1986-1991, Chiron Systems Inc and Plum Hall Inc.
3: * VERSION: 4
4: * DATE: 1993-01-01
5: * The "ANSI" mode of this suite corresponds to official ANSI C, X3.159-1989.
6: * As per your license agreement, your distribution is not to be moved or copied outside the Designated Site
7: * without specific permission from Plum Hall Inc.
8: */
9:
10: #include "flags.h"
11: #ifndef SKIP37
12: /*
13: * 3.7 - External Definitions
14: */
15: #include "defs.h"
16:
17: void c3_7_1();
18: static void c3_7_1a();
19: #if (ANSI || V7)
20: static void c3_7_1b();
21: #endif
22: static int seven();
23: void c3_7_2();
24:
25: void c3_7()
26: {
27: Filename = "c37.c";
28: c3_7_1(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
29: c3_7_2();
30: }
31:
32: /*
33: * 3.7.1 - Function definitions
34: */
35:
36: #if NEW_STYLE_FN_DEF
37: typedef void D;
38: void c3_7pro(double D, const char *pcc, unsigned char uc) /* called around line 104 below */
39: {
40: dequals(__LINE__, D, 123.);
41: iequals(__LINE__, pcc[0], 'a');
42: iequals(__LINE__, uc, UCHAR_MAX);
43: }
44: typedef int F(void); /* examples from 3.7.1 */
45: F f37, g37;
46: int f37(void) { return 37; }
47: int g37() { return 37; }
48: F *Fp = f37;
49: #endif
50:
51:
52:
53: /* 3.7.1 (cont.) */
54: extern void c3_7_1(i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
55: register int i;
56: register int j;
57: register int k;
58: register int l;
59: register int m;
60: register int n;
61: register int o;
62: register int p;
63: register int q;
64: register int r;
65: register int s;
66: register int t;
67: register int u;
68: register int v;
69: register int w;
70: register int x;
71: register int y;
72: register int z;
73: {
74: short ss;
75: char c;
76: float f;
77: static long larray[] = {1,2,3,4,5};
78: #if (ANSI || V7)
79: unsigned short us;
80: UCHAR uc;
81: #endif
82:
83: iequals(__LINE__, i, 1);
84: iequals(__LINE__, j, 2);
85: iequals(__LINE__, k, 3);
86: iequals(__LINE__, l, 4);
87: iequals(__LINE__, m, 5);
88: iequals(__LINE__, n, 6);
89: iequals(__LINE__, o, 7);
90: iequals(__LINE__, p, 8);
91: iequals(__LINE__, q, 9);
92: iequals(__LINE__, r, 10);
93: iequals(__LINE__, s, 11);
94: iequals(__LINE__, t, 12);
95: iequals(__LINE__, u, 13);
96: iequals(__LINE__, v, 14);
97: iequals(__LINE__, w, 15);
98: iequals(__LINE__, x, 16);
99: iequals(__LINE__, y, 17);
100: iequals(__LINE__, z, 18);
101:
102:
103: /* 3.7.1 (cont.) */
104: #if NEW_STYLE_FN_DEF
105: /* a new-style fn def serves as a proto */
106: c3_7pro(123, "ab", ULONG_MAX);
107: iequals(__LINE__, f37(), 37);
108: iequals(__LINE__, g37(), 37);
109: iequals(__LINE__, Fp(), 37);
110: #endif
111:
112: /* test conversion of parameters */
113: ss = SHRT_MAX; /* -> int */
114: c = CHAR_MAX; /* -> int */
115: f = 3.14; /* -> double */
116: c3_7_1a(0,0,0, ss, c, f, larray, seven);
117: #if (ANSI || V7)
118: us = MAX_USHORT;
119: uc = MAX_UCHAR;
120: c3_7_1b(0,0,0, (int)us, (int)uc, 0,0,0);
121: #endif
122:
123: }
124:
125: static void c3_7_1a(x1,x2,x3, ss, c, f, larray, pf)
126: /* order should not matter */
127: /* no argument declaration defaults to int */
128: int (*pf)();
129: long *larray;
130: double f;
131: {
132: long l;
133:
134: iequals(__LINE__, ss, (int)(short)SHRT_MAX);
135: iequals(__LINE__, c, (int)(char)CHAR_MAX);
136: fequals(__LINE__, f, 3.14);
137:
138: /* the array was passed as a pointer to the first element */
139: for (l = 0; l < 5; ++l)
140: lequals(__LINE__, l+1, larray[l]);
141: for (l = 1; l <= 5; ++l)
142: lequals(__LINE__, l, *larray++);
143:
144: /* the funtion name was passed as a pointer to the function */
145: iequals(__LINE__, (*pf)(), 7);
146:
147: /* each parm is an lvalue */
148: f = dvalue(1.);
149: dequals(__LINE__, f, 1.);
150: } /* end c3_7_1a */
151:
152:
153: /* 3.7.1 (cont.) */
154: static int seven()
155: {
156: return(7);
157: }
158:
159: #if (ANSI || V7)
160: /* no-argument-declaration defaults to int */
161: static void c3_7_1b(x1,x2,x3, us, uc, x4, x5, x6)
162: {
163: checkthat(__LINE__, us == (int)MAX_USHORT); /* same implem-def convert as the arg */
164: checkthat(__LINE__, uc == (int)MAX_UCHAR); /* same implem-def convert as the arg */
165: }
166: #endif
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203: /*
204: * 3.7.2 - External object definitions
205: */
206: int nodef;
207: #if ANSI
208: int hasdef;
209: #else
210: int hasdef = 4;
211: #endif
212:
213: /* the following external object definition examples were written
214: * by Plum for the X3J11 standard (slightly revised)
215: */
216: #if ANSI
217: int i1 = 1;
218: static int i2 = 2;
219: extern int i3 = 3;
220: int i4;
221: static int i5;
222:
223: int i1;
224: int i3;
225: int i4;
226:
227: extern int i1, i2, i3, i4, i5;
228: #endif
229:
230: void c3_7_2()
231: {
232: #if ANSI
233: iequals(__LINE__, i1, 1);
234: iequals(__LINE__, i2, 2);
235: iequals(__LINE__, i3, 3);
236: iequals(__LINE__, i4, 0);
237: iequals(__LINE__, i5, 0);
238: #endif
239:
240: /* some compilers will create nodef in the linker, some in the compiler.
241: * But all of them must be == 0.
242: */
243: iequals(__LINE__, nodef, 0);
244: iequals(__LINE__, hasdef, 4);
245: }
246: #if ANSI
247: int hasdef = 4;
248: #endif
249:
250:
251:
252:
253: #else /* if SKIP37 */
254:
255: void c3_7() { pr_skip("c3_7: SKIPPED ENTIRELY\n"); }
256: #endif /* SKIP37 */
257:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.