From d30f1626370880275c0e046e31c2d9942ab2fd3a Mon Sep 17 00:00:00 2001 From: Teddy Date: Sat, 5 Apr 2014 15:19:36 +0800 Subject: add testcases --- testcases/pass.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 testcases/pass.c (limited to 'testcases/pass.c') diff --git a/testcases/pass.c b/testcases/pass.c new file mode 100644 index 0000000..b219178 --- /dev/null +++ b/testcases/pass.c @@ -0,0 +1,80 @@ +int; +char; +struct {int x;}; +/* useless declarations are ok */ + +int a(int a); +int a(int d); +/* duplicate function declarations are ok */ + +struct A {int x; int y;} b; + +/* struct definitions in parameters is in a local scope + * subsequent parameter can make use of previous defined struct */ + +int foo(struct A {int x;} a, struct A b) { + /* function declaration in local scope is ok */ + int f(char *x); + /* A is defined in parameters */ + struct A c; + c.x = 43; +} + +void bar() { + /* struct definition is ok inside a function */ + struct A {int x;}; + struct A a; + a.x = 1; + { + /* the following `A' is different from previous one */ + struct A {int y;}; + struct A b; + b.y = 2; + } +} + +struct C c; +struct C { + struct D { + int x, y; + } b; + int c; + struct D d; +}; +struct D d; /* feasible here */ + +void nonsense() { + char q; + (void)q; + return "yay"; +} + +int assign() { + int *a; + struct {int *x;} b; + a = b.x; +} + +void incomplete() { + struct E {struct F *f;} e; +} + +void delay() { + struct G *g; + struct G {int x; }; + g->x = 1; +} + +void comma() { + int a; + int *b; + (b++, a++) * 3; +} + +struct Node n; +struct Node {int x, y;} n; +/* global forward declaration is ok */ +int main() { + n.x = 1; + n.y = 2; +} -- cgit v1.2.3