mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-21 06:30: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.
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
/* Deviance Test 8.7.0.1: Ensure illegal switch statements are detected */
|
|
|
|
#include <stdio.h>
|
|
|
|
int main (void)
|
|
{
|
|
int i = 3, j = 4;
|
|
unsigned short s = 7;
|
|
|
|
switch 3 /* omit switch expr's () */
|
|
default: ;
|
|
|
|
switch (i) /* non-constant case expressions */
|
|
{
|
|
case i * j: break;
|
|
case j: break;
|
|
}
|
|
|
|
switch (j) /* omit case expression */
|
|
case: break;
|
|
|
|
switch (i) /* non-unique case expressions */
|
|
{
|
|
case 3: break;
|
|
case 4: break;
|
|
default: break;
|
|
case 3: break;
|
|
}
|
|
|
|
switch (s) /* case expression of different */
|
|
{ /* type than switch expression */
|
|
case -3: break;
|
|
case -88: break;
|
|
}
|
|
|
|
switch (i) /* only 1 default label allowed */
|
|
{
|
|
case 1: break;
|
|
default: break;
|
|
case 2: default:
|
|
break;
|
|
}
|
|
|
|
case 22: i = 3; /* case label only allowed in switch body */
|
|
default: j = 90; /* default label only allowed in switch */
|
|
|
|
switch (76.443); /* switch expr can't be floating point typ*/
|
|
switch (&j + 1); /* switch expr can't be pointer type */
|
|
|
|
printf ("Failed Deviance Test 8.7.0.1\n");
|
|
}
|