mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-28 16:30:59 +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.
30 lines
988 B
C++
30 lines
988 B
C++
/* Deviance Test 4.6.6.1: Ensure illegal initialization of structures is */
|
|
/* detected */
|
|
|
|
int printf(const char *, ...);
|
|
|
|
struct S1 { int i;
|
|
float f; } s1 = { 3, 8.0, 'a' }; /* too many values */
|
|
|
|
struct S1 s2 = 2, 7.6; /* can't omit outer braces */
|
|
|
|
static struct S1 s3 = { 5, 5.0, 6.0, 77.77 }; /* too many values */
|
|
static struct S1 s4 = 0, 0.0; /* can't omit outer braces */
|
|
|
|
int main (void)
|
|
{
|
|
int i = 8;
|
|
float f = 3.5;
|
|
|
|
auto struct S1 s1 = { i * 2, f }; /* can only use constants */
|
|
register struct S1 s2 = { s1.i, f / 3.0 };
|
|
|
|
auto struct S1 s3 = { 4, 4, 5, }; /* too many values */
|
|
register struct S1 s4 = { 3, 2.0, 5.0E10 };
|
|
|
|
auto struct S1 s5 = 6, 17.9; /* can't omit outer braces */
|
|
register struct S1 s6 = 77, 90.0;
|
|
|
|
printf ("Failed Deviance Test 4.6.6.1\n");
|
|
}
|