diff options
author | Teddy <[email protected]> | 2014-04-05 15:19:36 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2014-04-05 15:19:36 +0800 |
commit | d30f1626370880275c0e046e31c2d9942ab2fd3a (patch) | |
tree | 42cc1a2b5a0d42cbcb0ebfdd6158172b0871752a /testcases | |
parent | bbb371767a3391c0b1c2222b9a9c87b4dbd36ef1 (diff) |
add testcases
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/fail1.c | 2 | ||||
-rw-r--r-- | testcases/fail2.c | 4 | ||||
-rw-r--r-- | testcases/fail3.c | 4 | ||||
-rw-r--r-- | testcases/fail4.c | 3 | ||||
-rw-r--r-- | testcases/fail5.c | 4 | ||||
-rw-r--r-- | testcases/fail6.c | 5 | ||||
-rw-r--r-- | testcases/fail7.c | 6 | ||||
-rw-r--r-- | testcases/pass.c | 80 |
8 files changed, 108 insertions, 0 deletions
diff --git a/testcases/fail1.c b/testcases/fail1.c new file mode 100644 index 0000000..f80ecaa --- /dev/null +++ b/testcases/fail1.c @@ -0,0 +1,2 @@ +int main(struct C c) { /* fail because of incomplete type of parameter */ +} diff --git a/testcases/fail2.c b/testcases/fail2.c new file mode 100644 index 0000000..a76d4e0 --- /dev/null +++ b/testcases/fail2.c @@ -0,0 +1,4 @@ +int main() { + /* fail because of incomplete type of local variable */ + struct C c; +} diff --git a/testcases/fail3.c b/testcases/fail3.c new file mode 100644 index 0000000..ad47f5f --- /dev/null +++ b/testcases/fail3.c @@ -0,0 +1,4 @@ +int main(int main) { + /* fail because `f' is overrided by parameter */ + main(3); +} diff --git a/testcases/fail4.c b/testcases/fail4.c new file mode 100644 index 0000000..20033af --- /dev/null +++ b/testcases/fail4.c @@ -0,0 +1,3 @@ +int main() { + (void)1 + 2; /* not ok */ +} diff --git a/testcases/fail5.c b/testcases/fail5.c new file mode 100644 index 0000000..0e8fba8 --- /dev/null +++ b/testcases/fail5.c @@ -0,0 +1,4 @@ +int main() { + /* fail because of incomplete field */ + struct C {struct B b;} *c; +} diff --git a/testcases/fail6.c b/testcases/fail6.c new file mode 100644 index 0000000..3419ce9 --- /dev/null +++ b/testcases/fail6.c @@ -0,0 +1,5 @@ +int main() { + struct C {int x;} *c; + /* fail because no member called `y' */ + c->y; +} diff --git a/testcases/fail7.c b/testcases/fail7.c new file mode 100644 index 0000000..5040408 --- /dev/null +++ b/testcases/fail7.c @@ -0,0 +1,6 @@ +int *main(int a,int b) { + struct {int x;} c; + /* fail because of wrong argument type */ + main(2, c); + return &a; +} 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; +} |