mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-29 13:34:04 +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.
116 lines
2.9 KiB
C++
116 lines
2.9 KiB
C++
/* Deviance Test 4.2.5.1: Ensure duplicate declarations of the same */
|
|
/* identifiers in the same overloading class and */
|
|
/* sharing the same scope are detected */
|
|
|
|
int printf(const char *, ...);
|
|
|
|
/* Errors at top level */
|
|
|
|
#define macro1 "hey" /* preprocessor macro names */
|
|
#define macro1 8
|
|
|
|
struct s1 { int a; /* type tags */
|
|
int b; };
|
|
union s1 { int x;
|
|
float y; };
|
|
enum s1 { a, b, c};
|
|
|
|
struct s2 { int r; /* component names */
|
|
char ch;
|
|
float r; };
|
|
union u1 { int x;
|
|
long x; };
|
|
|
|
double a [5]; /* all other names: variables, */
|
|
float *a; /* functions, typedef names, */
|
|
extern int F1 (void); /* enumeration constants */
|
|
int F1;
|
|
typedef float real;
|
|
float real;
|
|
enum flowers { rose, iris, daisy, thistle };
|
|
int rose;
|
|
|
|
int i;
|
|
typedef int i;
|
|
typedef double d1;
|
|
typedef int d1;
|
|
float F2 (int m);
|
|
typedef int *F2;
|
|
typedef float iris;
|
|
|
|
double p;
|
|
extern double p (void);
|
|
extern void Daisy (void);
|
|
typedef double doublePrec;
|
|
extern float doublePrec (void);
|
|
|
|
int L [10];
|
|
float one (int abc);
|
|
typedef int *two;
|
|
enum numbers { L, one, two };
|
|
|
|
|
|
/* Errors within a function */
|
|
|
|
int main (void)
|
|
{
|
|
#define macro99 99 /* preprocessor macro names */
|
|
#define macro99 999
|
|
|
|
struct ll { char z; /* type tags */
|
|
int m; };
|
|
union ll { int x;
|
|
float y; };
|
|
enum ll { lll, llll, lllll };
|
|
|
|
struct jy { float f0; /* component names */
|
|
char ch;
|
|
float f0; };
|
|
union u1 { int x [3];
|
|
long x; };
|
|
|
|
double b [5]; /* all other names: variables, */
|
|
float *b; /* functions, typedef names, */
|
|
int Moth (int m0); /* enumeration constants */
|
|
int Moth;
|
|
typedef extended ext;
|
|
double ext;
|
|
enum people { Joe, Mike, Patty, Jim };
|
|
char Jim;
|
|
|
|
float floatOne;
|
|
typedef float floatOne;
|
|
typedef int *repeatIt;
|
|
typedef int *repeatIt;
|
|
extended Ext2 (extended ext2);
|
|
typedef int *Ext2;
|
|
typedef void Joe;
|
|
|
|
long aLongNum;
|
|
extern long aLongNum (long longLong);
|
|
extern void Mike (int Patty);
|
|
typedef unsigned UnSigned;
|
|
extern int UnSigned (void);
|
|
|
|
extended array [98];
|
|
double Func1 (double doubleDouble);
|
|
typedef long *Long;
|
|
enum objects { array, Long, Func1 };
|
|
|
|
printf ("Failed Deviance Test 4.2.5.1\n");
|
|
}
|
|
|
|
/* Two functions with same name */
|
|
|
|
/****************************************************************************/
|
|
|
|
int Xx (void)
|
|
{
|
|
}
|
|
|
|
/****************************************************************************/
|
|
|
|
double Xx (char a)
|
|
{
|
|
}
|