mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-06 00:29:41 +00:00
91d33b586d
The main changes made to most tests are: *Declarations always include explicit types, not relying on implicit int. The declaration of main in most test programs is changed to be "int main (void) {...}", adding an explicit return type and a prototype. (There are still some non-prototyped functions, though.) *Functions are always declared before use, either by including a header or by providing a declaration for the specific function. The latter approach is usually used for printf, to avoid requiring ORCA/C to process stdio.h when compiling every test case (which might make test runs noticeably slower). *Make all return statements in non-void functions (e.g. main) return a value. *Avoid some instances of undefined behavior and type errors in printf and scanf calls. Several miscellaneous bugs are also fixed. There are still a couple test cases that intentionally rely on the C89 behavior, to ensure it still works.
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
/* Special Conformance Test 4.5.3.1: Verfication of global array declarations */
|
|
/* */
|
|
/* Other files needed: spc4531.exec - Separately compiles, links, and */
|
|
/* executes the files needed to run test */
|
|
/* spc4531.1.cc - Extern function which tests the arrays */
|
|
/* spc4531.h - Header file declaring global arrays */
|
|
|
|
int printf(const char *, ...);
|
|
|
|
int i1 [50], i3 [3] [5] [8]; /* all basic types */
|
|
long L1 [9], L2 [2] [6];
|
|
|
|
unsigned int ui3 [4] [5] [1], ui1 [7];
|
|
unsigned long ul2 [5] [3], ul1 [1];
|
|
|
|
comp c1 [3], c2 [2] [3];
|
|
char ch2 [6] [5], ch1 [10];
|
|
float f1 [3], f4 [2] [3] [1] [4];
|
|
double d2 [2] [4], d1 [8];
|
|
extended e1 [9], e2 [7] [3];
|
|
|
|
/* conglomerate types */
|
|
struct s { int a;
|
|
float f; };
|
|
struct s s1 [10], s2 [5] [4];
|
|
|
|
enum colors { red, black, green };
|
|
enum colors C3 [2] [1] [3], C1 [6];
|
|
|
|
union longOrShort { int first;
|
|
long second; };
|
|
union longOrShort u2 [3] [3], u1 [12];
|
|
|
|
int main (void)
|
|
{
|
|
extern int TestArray (void);
|
|
|
|
if ( TestArray() )
|
|
printf ("Passed Special Conformance Test 4.5.3.1\n");
|
|
else
|
|
printf ("Failed Special Conformance Test 4.5.3.1\n");
|
|
}
|