From 52b29440f8f1310e0c074c8eb409e433c56bdd62 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 7 May 2014 03:17:32 +0800 Subject: rename --- compile_data/custom_const.c | 9 ++ compile_data/custom_struct.c | 26 +++++ compile_data/custom_struct2.c | 41 ++++++++ compile_data/custom_struct3.c | 15 +++ compile_data/custom_struct4.c | 28 ++++++ compile_data/custom_subexp.c | 9 ++ compile_data/custom_subexp2.c | 10 ++ compile_data/func_pointer.c | 19 ++++ dom.c | 155 ----------------------------- obsolete/dom.c | 155 +++++++++++++++++++++++++++++ run.sh | 18 ---- semantics_data/anonymous_struct1.c | 6 ++ semantics_data/anonymous_struct2.c | 7 ++ semantics_data/array_complete.c | 4 + semantics_data/array_decl.c | 6 ++ semantics_data/array_decl2.c | 7 ++ semantics_data/cast.c | 3 + semantics_data/cast2.c | 3 + semantics_data/cast3.c | 3 + semantics_data/conflict.c | 4 + semantics_data/decl_comp.c | 5 + semantics_data/decl_comp2.c | 5 + semantics_data/decl_comp3.c | 4 + semantics_data/fail1.c | 2 + semantics_data/fail10.c | 4 + semantics_data/fail11.c | 4 + semantics_data/fail2.c | 4 + semantics_data/fail3.c | 4 + semantics_data/fail4.c | 3 + semantics_data/fail5.c | 4 + semantics_data/fail6.c | 5 + semantics_data/fail7.c | 6 ++ semantics_data/fail8.c | 5 + semantics_data/function_returns_function.c | 1 + semantics_data/global_decl.c | 3 + semantics_data/incomp_initr.c | 4 + semantics_data/incomp_param.c | 5 + semantics_data/local_struct.c | 7 ++ semantics_data/param1.c | 5 + semantics_data/param2.c | 4 + semantics_data/param3.c | 4 + semantics_data/pass.c | 147 +++++++++++++++++++++++++++ semantics_data/ref.c | 4 + semantics_data/sizeof.c | 3 + semantics_data/typedef1.c | 4 + semantics_data/typedef2.c | 4 + semantics_data/typedef3.c | 4 + semantics_data/typedef4.c | 10 ++ semantics_data/void_decl.c | 3 + semantics_data/void_decl2.c | 5 + test_all.sh | 20 ---- test_compile.sh | 18 ++++ test_semantics.sh | 20 ++++ testbed/custom_const.c | 9 -- testbed/custom_struct.c | 26 ----- testbed/custom_struct2.c | 41 -------- testbed/custom_struct3.c | 15 --- testbed/custom_struct4.c | 28 ------ testbed/custom_subexp.c | 9 -- testbed/custom_subexp2.c | 10 -- testbed/func_pointer.c | 19 ---- testcases/anonymous_struct1.c | 6 -- testcases/anonymous_struct2.c | 7 -- testcases/array_complete.c | 4 - testcases/array_decl.c | 6 -- testcases/array_decl2.c | 7 -- testcases/cast.c | 3 - testcases/cast2.c | 3 - testcases/cast3.c | 3 - testcases/conflict.c | 4 - testcases/decl_comp.c | 5 - testcases/decl_comp2.c | 5 - testcases/decl_comp3.c | 4 - testcases/fail1.c | 2 - testcases/fail10.c | 4 - testcases/fail11.c | 4 - testcases/fail2.c | 4 - testcases/fail3.c | 4 - testcases/fail4.c | 3 - testcases/fail5.c | 4 - testcases/fail6.c | 5 - testcases/fail7.c | 6 -- testcases/fail8.c | 5 - testcases/function_returns_function.c | 1 - testcases/global_decl.c | 3 - testcases/incomp_initr.c | 4 - testcases/incomp_param.c | 5 - testcases/local_struct.c | 7 -- testcases/param1.c | 5 - testcases/param2.c | 4 - testcases/param3.c | 4 - testcases/pass.c | 147 --------------------------- testcases/ref.c | 4 - testcases/sizeof.c | 3 - testcases/typedef1.c | 4 - testcases/typedef2.c | 4 - testcases/typedef3.c | 4 - testcases/typedef4.c | 10 -- testcases/void_decl.c | 3 - testcases/void_decl2.c | 5 - 100 files changed, 665 insertions(+), 665 deletions(-) create mode 100644 compile_data/custom_const.c create mode 100644 compile_data/custom_struct.c create mode 100644 compile_data/custom_struct2.c create mode 100644 compile_data/custom_struct3.c create mode 100644 compile_data/custom_struct4.c create mode 100644 compile_data/custom_subexp.c create mode 100644 compile_data/custom_subexp2.c create mode 100644 compile_data/func_pointer.c delete mode 100644 dom.c create mode 100644 obsolete/dom.c delete mode 100755 run.sh create mode 100644 semantics_data/anonymous_struct1.c create mode 100644 semantics_data/anonymous_struct2.c create mode 100644 semantics_data/array_complete.c create mode 100644 semantics_data/array_decl.c create mode 100644 semantics_data/array_decl2.c create mode 100644 semantics_data/cast.c create mode 100644 semantics_data/cast2.c create mode 100644 semantics_data/cast3.c create mode 100644 semantics_data/conflict.c create mode 100644 semantics_data/decl_comp.c create mode 100644 semantics_data/decl_comp2.c create mode 100644 semantics_data/decl_comp3.c create mode 100644 semantics_data/fail1.c create mode 100644 semantics_data/fail10.c create mode 100644 semantics_data/fail11.c create mode 100644 semantics_data/fail2.c create mode 100644 semantics_data/fail3.c create mode 100644 semantics_data/fail4.c create mode 100644 semantics_data/fail5.c create mode 100644 semantics_data/fail6.c create mode 100644 semantics_data/fail7.c create mode 100644 semantics_data/fail8.c create mode 100644 semantics_data/function_returns_function.c create mode 100644 semantics_data/global_decl.c create mode 100644 semantics_data/incomp_initr.c create mode 100644 semantics_data/incomp_param.c create mode 100644 semantics_data/local_struct.c create mode 100644 semantics_data/param1.c create mode 100644 semantics_data/param2.c create mode 100644 semantics_data/param3.c create mode 100644 semantics_data/pass.c create mode 100644 semantics_data/ref.c create mode 100644 semantics_data/sizeof.c create mode 100644 semantics_data/typedef1.c create mode 100644 semantics_data/typedef2.c create mode 100644 semantics_data/typedef3.c create mode 100644 semantics_data/typedef4.c create mode 100644 semantics_data/void_decl.c create mode 100644 semantics_data/void_decl2.c delete mode 100755 test_all.sh create mode 100755 test_compile.sh create mode 100755 test_semantics.sh delete mode 100644 testbed/custom_const.c delete mode 100644 testbed/custom_struct.c delete mode 100644 testbed/custom_struct2.c delete mode 100644 testbed/custom_struct3.c delete mode 100644 testbed/custom_struct4.c delete mode 100644 testbed/custom_subexp.c delete mode 100644 testbed/custom_subexp2.c delete mode 100644 testbed/func_pointer.c delete mode 100644 testcases/anonymous_struct1.c delete mode 100644 testcases/anonymous_struct2.c delete mode 100644 testcases/array_complete.c delete mode 100644 testcases/array_decl.c delete mode 100644 testcases/array_decl2.c delete mode 100644 testcases/cast.c delete mode 100644 testcases/cast2.c delete mode 100644 testcases/cast3.c delete mode 100644 testcases/conflict.c delete mode 100644 testcases/decl_comp.c delete mode 100644 testcases/decl_comp2.c delete mode 100644 testcases/decl_comp3.c delete mode 100644 testcases/fail1.c delete mode 100644 testcases/fail10.c delete mode 100644 testcases/fail11.c delete mode 100644 testcases/fail2.c delete mode 100644 testcases/fail3.c delete mode 100644 testcases/fail4.c delete mode 100644 testcases/fail5.c delete mode 100644 testcases/fail6.c delete mode 100644 testcases/fail7.c delete mode 100644 testcases/fail8.c delete mode 100644 testcases/function_returns_function.c delete mode 100644 testcases/global_decl.c delete mode 100644 testcases/incomp_initr.c delete mode 100644 testcases/incomp_param.c delete mode 100644 testcases/local_struct.c delete mode 100644 testcases/param1.c delete mode 100644 testcases/param2.c delete mode 100644 testcases/param3.c delete mode 100644 testcases/pass.c delete mode 100644 testcases/ref.c delete mode 100644 testcases/sizeof.c delete mode 100644 testcases/typedef1.c delete mode 100644 testcases/typedef2.c delete mode 100644 testcases/typedef3.c delete mode 100644 testcases/typedef4.c delete mode 100644 testcases/void_decl.c delete mode 100644 testcases/void_decl2.c diff --git a/compile_data/custom_const.c b/compile_data/custom_const.c new file mode 100644 index 0000000..d0126f3 --- /dev/null +++ b/compile_data/custom_const.c @@ -0,0 +1,9 @@ +int sum; +void f() { + sum = 3; +} +int main() { + sum = 1; + f(); + printf("%d\n", sum); +} diff --git a/compile_data/custom_struct.c b/compile_data/custom_struct.c new file mode 100644 index 0000000..0d473f5 --- /dev/null +++ b/compile_data/custom_struct.c @@ -0,0 +1,26 @@ +struct D { + int a, b; +}; +struct A { + int a[100]; + struct B { + struct C { + int x, y; + } c; + int z; + struct D *p; + } b; +} s; +int main() { + struct D d; + int n = 0; + s.a[1] = 1; + s.a[2] = 2; + s.b.z = 4; + s.b.c.x = 5; + s.b.c.y = 6; + s.b.p = &d; + s.b.p->a = 7; + s.b.p->b = 8; + printf("%d %d %d %d %d %d %d\n", s.a[1], s.a[2], s.b.z, s.b.c.x, s.b.c.y, s.b.p->a, s.b.p->b); +} diff --git a/compile_data/custom_struct2.c b/compile_data/custom_struct2.c new file mode 100644 index 0000000..e147186 --- /dev/null +++ b/compile_data/custom_struct2.c @@ -0,0 +1,41 @@ +struct A { + int x, y; +} sa; +struct A print(struct A a, struct A b) { + a.x++; + a.y++; + b.x--; + b.y--; + printf("args: %d %d\n", a.x, a.y); + printf("args: %d %d\n", b.x, b.y); + return a; +} +int main() { + int i; + int t; + int *a, *b; + struct A sb, sc; + a = malloc(sizeof(int) * 100); + for (i = 0; i < 100; i++) + a[i] = i; + b = malloc(sizeof(int) * 100); + memcpy(b, a, sizeof(int) * 100); + for (i = 0; i < 100; i++) + printf("%d ", b[i]); + sb.x = 1; + sb.y = 2; + sa = sb; + sc = sa; + printf("\n%d %d\n", sa.x, sa.y); + printf("%d %d\n", sc.x, sc.y); + sa.x = 1; + sa.y = 2; + sb.x = 1; + sb.y = 2; + sa = print(sa, sb); + sb = print(sa, sb); + sa = print(sa, sb); + sb = print(sa, sb); + printf("%d %d\n", sa.x, sa.y); + printf("%d %d\n", sb.x, sb.y); +} diff --git a/compile_data/custom_struct3.c b/compile_data/custom_struct3.c new file mode 100644 index 0000000..d7060b3 --- /dev/null +++ b/compile_data/custom_struct3.c @@ -0,0 +1,15 @@ +struct A { + int x, y; +} a[10]; +struct A f(struct A a) { + a.x++; + a.y++; + return a; +} +int main(){ + int i; + for (i = 1; i < 10; i++) + a[i] = f(a[i - 1]); + for (i = 0; i < 10; i++) + printf("%d %d\n", a[i].x, a[i].y); +} diff --git a/compile_data/custom_struct4.c b/compile_data/custom_struct4.c new file mode 100644 index 0000000..75f50ea --- /dev/null +++ b/compile_data/custom_struct4.c @@ -0,0 +1,28 @@ +struct A { + struct B { + int x, y; + struct C { + int w; + } c; + } b; + int z; +}; + +struct B f(struct A a) { + printf("z: %d\n", a.z); + return a.b; +} + +struct C g(struct B b) { + printf("x: %d\ny: %d\n", b.x, b.y); + return b.c; +} + +int main() { + struct A a; + a.z = 1; + a.b.x = 2; + a.b.y = 3; + a.b.c.w = 4; + printf("w: %d\n", g(f(a)).w); +} diff --git a/compile_data/custom_subexp.c b/compile_data/custom_subexp.c new file mode 100644 index 0000000..bce5bdb --- /dev/null +++ b/compile_data/custom_subexp.c @@ -0,0 +1,9 @@ +int N = 0; +void f() { N = 2; } +int main() { + int a, b; + a = N + 1; + f(); + b = N + 1; + printf("%d\n", b); +} diff --git a/compile_data/custom_subexp2.c b/compile_data/custom_subexp2.c new file mode 100644 index 0000000..1e4af93 --- /dev/null +++ b/compile_data/custom_subexp2.c @@ -0,0 +1,10 @@ +int flag = 0; +int check(int x, int y) { + return x > 0 && y > 0 && (flag ^= 1); +} +int main() { + int x = 1, y = 2; + printf("%d\n", check(x, y)); + printf("%d\n", check(x, y)); + printf("%d\n", check(x, y)); +} diff --git a/compile_data/func_pointer.c b/compile_data/func_pointer.c new file mode 100644 index 0000000..e7b6484 --- /dev/null +++ b/compile_data/func_pointer.c @@ -0,0 +1,19 @@ +typedef void (*Func_t)(); +void f(Func_t func, int step) { + if (!step) return; + printf("i'm f\n"); + func(func, step - 1); +} +void g(void (*func)(), int step) { + if (!step) return; + printf("i'm g\n"); + func(func, step - 1); +} +int main() { + void (*func)(void (*ifunc)(), int step); + int x = 1; + if (x) func = f; + else func = g; + func(func, 5); + return 0; +} diff --git a/dom.c b/dom.c deleted file mode 100644 index c6eaa97..0000000 --- a/dom.c +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include -#include -#define MAXN 1000 -#define MAX_HASH 1021 -typedef struct Edge Edge; -typedef struct Set Set; -typedef Set *Set_t; -typedef struct SetNode { - int val; - struct SetNode *next; -} SetNode; -struct Set { - SetNode *head[MAX_HASH]; -}; - -Set_t set_create() { - Set_t set = (Set_t)malloc(sizeof(Set)); - memset(set->head, 0, sizeof set->head); - return set; -} - -int set_belongs(Set_t set, int val) { - SetNode *p; - for (p = set->head[val % MAX_HASH]; p; p = p->next) - if (p->val == val) return 1; - return 0; -} - -void set_push(Set_t set, int val) { - SetNode *p = (SetNode*)malloc(sizeof(SetNode)); - int hv = val % MAX_HASH; - p->next = set->head[hv]; - p->val = val; - set->head[hv] = p; -} - -struct Edge { - int to; - Edge *next; -} *head[MAXN], *rhead[MAXN]; - -typedef struct DFNode DFNode; -struct DFNode { - int id; - DFNode *next; -}; - -void add_edge(int a, int b, Edge **head) { - Edge *p = (Edge*)malloc(sizeof(Edge)); - p->to = b; - p->next = head[a]; - head[a] = p; -} -int dom[MAXN], ord[MAXN], vis[MAXN], par[MAXN]; -int n, n0, m; -DFNode *df[MAXN]; -Set_t dfset[MAXN]; - -void dfs(int u, int v) { - static int ocnt = 0; - Edge *e; - if (vis[u] != -1) return; - par[u] = v; - vis[u] = 0; - for (e = head[u]; e; e = e->next) - dfs(e->to, u); - vis[u] = ocnt; - ord[ocnt++] = u; -} - -int intersect(int b1, int b2) { - while (b1 != b2) - if (b1 < b2) b1 = dom[b1]; - else b2 = dom[b2]; - return b1; -} - -int main() { - int i; - int ch = 1; - scanf("%d %d %d", &n, &m, &n0); - for (i = 0; i < m; i++) - { - int a, b; - scanf("%d %d", &a, &b); - add_edge(a, b, head); - add_edge(b, a, rhead); - } - for (i = 0; i < n; i++) - vis[i] = dom[i] = -1; - dfs(n0, -1); - for (i = 0; i < n; i++) - printf("%d ", ord[i]); puts(""); - dom[vis[n0]] = vis[n0]; - while (ch) - { - int i; - ch = 0; - for (i = n - 2; i >= 0; i--) - { - int id = ord[i]; - Edge *e = rhead[id]; - int new_idom = vis[par[id]]; - for (; e; e = e->next) - { - int p = e->to; - if (vis[p] == new_idom) continue; - if (dom[vis[p]] != -1) - new_idom = intersect(vis[p], new_idom); - } - if (dom[i] != new_idom) - { - ch = 1; - dom[i] = new_idom; - } - } - for (i = 0; i < n; i++) - printf("%d ", ord[dom[vis[i]]]); puts(""); - } - for (i = 0; i < n; i++) - { - dfset[i] = set_create(); - df[i] = NULL; - } - for (i = 0; i < n; i++) - if (rhead[i] && rhead[i]->next) - { - Edge *p = rhead[i]; - for (; p; p = p->next) - { - int runner = p->to; - while (vis[runner] != dom[vis[i]]) - { - if (!set_belongs(dfset[runner], i)) - { - DFNode *np = (DFNode*)malloc(sizeof(DFNode)); - np->id = i; - np->next = df[runner]; - set_push(dfset[runner], i); - df[runner] = np; - } - runner = ord[dom[vis[runner]]]; - } - } - } - for (i = 0; i < n; i++) - { - DFNode *p = df[i]; - printf("%d: ", i); - for (; p; p = p->next) - printf("%d ", p->id); puts(""); - } - return 0; -} diff --git a/obsolete/dom.c b/obsolete/dom.c new file mode 100644 index 0000000..c6eaa97 --- /dev/null +++ b/obsolete/dom.c @@ -0,0 +1,155 @@ +#include +#include +#include +#define MAXN 1000 +#define MAX_HASH 1021 +typedef struct Edge Edge; +typedef struct Set Set; +typedef Set *Set_t; +typedef struct SetNode { + int val; + struct SetNode *next; +} SetNode; +struct Set { + SetNode *head[MAX_HASH]; +}; + +Set_t set_create() { + Set_t set = (Set_t)malloc(sizeof(Set)); + memset(set->head, 0, sizeof set->head); + return set; +} + +int set_belongs(Set_t set, int val) { + SetNode *p; + for (p = set->head[val % MAX_HASH]; p; p = p->next) + if (p->val == val) return 1; + return 0; +} + +void set_push(Set_t set, int val) { + SetNode *p = (SetNode*)malloc(sizeof(SetNode)); + int hv = val % MAX_HASH; + p->next = set->head[hv]; + p->val = val; + set->head[hv] = p; +} + +struct Edge { + int to; + Edge *next; +} *head[MAXN], *rhead[MAXN]; + +typedef struct DFNode DFNode; +struct DFNode { + int id; + DFNode *next; +}; + +void add_edge(int a, int b, Edge **head) { + Edge *p = (Edge*)malloc(sizeof(Edge)); + p->to = b; + p->next = head[a]; + head[a] = p; +} +int dom[MAXN], ord[MAXN], vis[MAXN], par[MAXN]; +int n, n0, m; +DFNode *df[MAXN]; +Set_t dfset[MAXN]; + +void dfs(int u, int v) { + static int ocnt = 0; + Edge *e; + if (vis[u] != -1) return; + par[u] = v; + vis[u] = 0; + for (e = head[u]; e; e = e->next) + dfs(e->to, u); + vis[u] = ocnt; + ord[ocnt++] = u; +} + +int intersect(int b1, int b2) { + while (b1 != b2) + if (b1 < b2) b1 = dom[b1]; + else b2 = dom[b2]; + return b1; +} + +int main() { + int i; + int ch = 1; + scanf("%d %d %d", &n, &m, &n0); + for (i = 0; i < m; i++) + { + int a, b; + scanf("%d %d", &a, &b); + add_edge(a, b, head); + add_edge(b, a, rhead); + } + for (i = 0; i < n; i++) + vis[i] = dom[i] = -1; + dfs(n0, -1); + for (i = 0; i < n; i++) + printf("%d ", ord[i]); puts(""); + dom[vis[n0]] = vis[n0]; + while (ch) + { + int i; + ch = 0; + for (i = n - 2; i >= 0; i--) + { + int id = ord[i]; + Edge *e = rhead[id]; + int new_idom = vis[par[id]]; + for (; e; e = e->next) + { + int p = e->to; + if (vis[p] == new_idom) continue; + if (dom[vis[p]] != -1) + new_idom = intersect(vis[p], new_idom); + } + if (dom[i] != new_idom) + { + ch = 1; + dom[i] = new_idom; + } + } + for (i = 0; i < n; i++) + printf("%d ", ord[dom[vis[i]]]); puts(""); + } + for (i = 0; i < n; i++) + { + dfset[i] = set_create(); + df[i] = NULL; + } + for (i = 0; i < n; i++) + if (rhead[i] && rhead[i]->next) + { + Edge *p = rhead[i]; + for (; p; p = p->next) + { + int runner = p->to; + while (vis[runner] != dom[vis[i]]) + { + if (!set_belongs(dfset[runner], i)) + { + DFNode *np = (DFNode*)malloc(sizeof(DFNode)); + np->id = i; + np->next = df[runner]; + set_push(dfset[runner], i); + df[runner] = np; + } + runner = ord[dom[vis[runner]]]; + } + } + } + for (i = 0; i < n; i++) + { + DFNode *p = df[i]; + printf("%d: ", i); + for (; p; p = p->next) + printf("%d ", p->id); puts(""); + } + return 0; +} diff --git a/run.sh b/run.sh deleted file mode 100755 index a3f67c3..0000000 --- a/run.sh +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/bash -cp cibic testbed/ -cp lib.s testbed/ -cd testbed/ -for f in *.c -do - echo $f - ./cibic $f > mips.s 2> /dev/null - gcc $f -m32 -std=c99 2> /dev/null - ./spim -stat -file mips.s > out - ./a.out > std - diff std out - if [[ "$?" != 0 ]]; then - echo "Wrong Answer!" - break; - fi -done -echo "OK." diff --git a/semantics_data/anonymous_struct1.c b/semantics_data/anonymous_struct1.c new file mode 100644 index 0000000..2709f70 --- /dev/null +++ b/semantics_data/anonymous_struct1.c @@ -0,0 +1,6 @@ +int main() { + struct {int x, y;} a, b, c; + a = b; + b = c; + c = a; +} diff --git a/semantics_data/anonymous_struct2.c b/semantics_data/anonymous_struct2.c new file mode 100644 index 0000000..b17e6c0 --- /dev/null +++ b/semantics_data/anonymous_struct2.c @@ -0,0 +1,7 @@ +int main() { + struct {int x, y;} a; + struct {int x, y;} b, c; + a = b; + b = c; + c = a; +} diff --git a/semantics_data/array_complete.c b/semantics_data/array_complete.c new file mode 100644 index 0000000..79c5c8a --- /dev/null +++ b/semantics_data/array_complete.c @@ -0,0 +1,4 @@ +struct A arr[1]; +struct A {int x;}; +int main() { +} diff --git a/semantics_data/array_decl.c b/semantics_data/array_decl.c new file mode 100644 index 0000000..33973e5 --- /dev/null +++ b/semantics_data/array_decl.c @@ -0,0 +1,6 @@ +int f(int a[1][3][2]) { +} +int main() { + int a[3][3][2]; + f(a); +} diff --git a/semantics_data/array_decl2.c b/semantics_data/array_decl2.c new file mode 100644 index 0000000..d7f8a04 --- /dev/null +++ b/semantics_data/array_decl2.c @@ -0,0 +1,7 @@ +int f(int a[20][2][2]); +int f(int a[1][3][2]) { +} +int main() { + int a[3][3][2]; + f(a); +} diff --git a/semantics_data/cast.c b/semantics_data/cast.c new file mode 100644 index 0000000..b441552 --- /dev/null +++ b/semantics_data/cast.c @@ -0,0 +1,3 @@ +int main() { + ((int (*)(int a))1)(1); +} diff --git a/semantics_data/cast2.c b/semantics_data/cast2.c new file mode 100644 index 0000000..34b3484 --- /dev/null +++ b/semantics_data/cast2.c @@ -0,0 +1,3 @@ +int main() { + (int [3])1; +} diff --git a/semantics_data/cast3.c b/semantics_data/cast3.c new file mode 100644 index 0000000..4500cb1 --- /dev/null +++ b/semantics_data/cast3.c @@ -0,0 +1,3 @@ +int main() { + (int ())1; +} diff --git a/semantics_data/conflict.c b/semantics_data/conflict.c new file mode 100644 index 0000000..f2798e7 --- /dev/null +++ b/semantics_data/conflict.c @@ -0,0 +1,4 @@ +int f(int a, char b); +int f(int a); +int main() { +} diff --git a/semantics_data/decl_comp.c b/semantics_data/decl_comp.c new file mode 100644 index 0000000..f1b8bd2 --- /dev/null +++ b/semantics_data/decl_comp.c @@ -0,0 +1,5 @@ +int f(); +int f(int a); +int main() { + f(1, 2); +} diff --git a/semantics_data/decl_comp2.c b/semantics_data/decl_comp2.c new file mode 100644 index 0000000..f1298bd --- /dev/null +++ b/semantics_data/decl_comp2.c @@ -0,0 +1,5 @@ +int f(int a); +int f() { +} +int main() { +} diff --git a/semantics_data/decl_comp3.c b/semantics_data/decl_comp3.c new file mode 100644 index 0000000..29d388f --- /dev/null +++ b/semantics_data/decl_comp3.c @@ -0,0 +1,4 @@ +int f(); +int f(int a) { + f(); +} diff --git a/semantics_data/fail1.c b/semantics_data/fail1.c new file mode 100644 index 0000000..f80ecaa --- /dev/null +++ b/semantics_data/fail1.c @@ -0,0 +1,2 @@ +int main(struct C c) { /* fail because of incomplete type of parameter */ +} diff --git a/semantics_data/fail10.c b/semantics_data/fail10.c new file mode 100644 index 0000000..e287c6f --- /dev/null +++ b/semantics_data/fail10.c @@ -0,0 +1,4 @@ +int main() { + int a[2][3]; + a[1][3][3] = 3; +} diff --git a/semantics_data/fail11.c b/semantics_data/fail11.c new file mode 100644 index 0000000..4aa213a --- /dev/null +++ b/semantics_data/fail11.c @@ -0,0 +1,4 @@ +int main() { + int a[2][3]; + a[1] = 3; +} diff --git a/semantics_data/fail2.c b/semantics_data/fail2.c new file mode 100644 index 0000000..a76d4e0 --- /dev/null +++ b/semantics_data/fail2.c @@ -0,0 +1,4 @@ +int main() { + /* fail because of incomplete type of local variable */ + struct C c; +} diff --git a/semantics_data/fail3.c b/semantics_data/fail3.c new file mode 100644 index 0000000..ad47f5f --- /dev/null +++ b/semantics_data/fail3.c @@ -0,0 +1,4 @@ +int main(int main) { + /* fail because `f' is overrided by parameter */ + main(3); +} diff --git a/semantics_data/fail4.c b/semantics_data/fail4.c new file mode 100644 index 0000000..20033af --- /dev/null +++ b/semantics_data/fail4.c @@ -0,0 +1,3 @@ +int main() { + (void)1 + 2; /* not ok */ +} diff --git a/semantics_data/fail5.c b/semantics_data/fail5.c new file mode 100644 index 0000000..0e8fba8 --- /dev/null +++ b/semantics_data/fail5.c @@ -0,0 +1,4 @@ +int main() { + /* fail because of incomplete field */ + struct C {struct B b;} *c; +} diff --git a/semantics_data/fail6.c b/semantics_data/fail6.c new file mode 100644 index 0000000..3419ce9 --- /dev/null +++ b/semantics_data/fail6.c @@ -0,0 +1,5 @@ +int main() { + struct C {int x;} *c; + /* fail because no member called `y' */ + c->y; +} diff --git a/semantics_data/fail7.c b/semantics_data/fail7.c new file mode 100644 index 0000000..5040408 --- /dev/null +++ b/semantics_data/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/semantics_data/fail8.c b/semantics_data/fail8.c new file mode 100644 index 0000000..21efd5f --- /dev/null +++ b/semantics_data/fail8.c @@ -0,0 +1,5 @@ +struct { + int f(); +}; +int main() { +} diff --git a/semantics_data/function_returns_function.c b/semantics_data/function_returns_function.c new file mode 100644 index 0000000..e590ddb --- /dev/null +++ b/semantics_data/function_returns_function.c @@ -0,0 +1 @@ +int main()() {} diff --git a/semantics_data/global_decl.c b/semantics_data/global_decl.c new file mode 100644 index 0000000..ff49829 --- /dev/null +++ b/semantics_data/global_decl.c @@ -0,0 +1,3 @@ +int x = x; +int main() { +} diff --git a/semantics_data/incomp_initr.c b/semantics_data/incomp_initr.c new file mode 100644 index 0000000..1068284 --- /dev/null +++ b/semantics_data/incomp_initr.c @@ -0,0 +1,4 @@ +int main() { + struct A {int x, y;} b; + int a[(1 + 1 == 2) * 2] = {1, b}; +} diff --git a/semantics_data/incomp_param.c b/semantics_data/incomp_param.c new file mode 100644 index 0000000..c1ece5f --- /dev/null +++ b/semantics_data/incomp_param.c @@ -0,0 +1,5 @@ +int f(struct A a, int b) { + +} +int main() { +} diff --git a/semantics_data/local_struct.c b/semantics_data/local_struct.c new file mode 100644 index 0000000..28cb223 --- /dev/null +++ b/semantics_data/local_struct.c @@ -0,0 +1,7 @@ +struct A {int x; int y; } b; +int f(struct A {int a;} p) { + struct A a; + a.x; +} +int main() { +} diff --git a/semantics_data/param1.c b/semantics_data/param1.c new file mode 100644 index 0000000..6c22a2b --- /dev/null +++ b/semantics_data/param1.c @@ -0,0 +1,5 @@ +int f(); +int f() {} +int main() { + f(1, 2, 3); +} diff --git a/semantics_data/param2.c b/semantics_data/param2.c new file mode 100644 index 0000000..6b1726d --- /dev/null +++ b/semantics_data/param2.c @@ -0,0 +1,4 @@ +int f(); +int f(int a) {} +int main() { +} diff --git a/semantics_data/param3.c b/semantics_data/param3.c new file mode 100644 index 0000000..8492455 --- /dev/null +++ b/semantics_data/param3.c @@ -0,0 +1,4 @@ +int f(int a); +int f() {} +int main() { +} diff --git a/semantics_data/pass.c b/semantics_data/pass.c new file mode 100644 index 0000000..a7d4481 --- /dev/null +++ b/semantics_data/pass.c @@ -0,0 +1,147 @@ +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; +} + +int complex_pointer() { + int (*g(int ***e[10]))(); +} + +int fp(int a, int b, int c) { + int (*f)(int a, int b, int c); + f = ****fp + 1; + (****f)(1, 2, 3); + f = &fp + 1; +} + +int fc(int fc()) { + fc(complex_pointer); +} + +int incomp(struct I a); +struct I { int i, j; }; + +void (*bsd_signal(int sig, void (*func)(int a)))(int b); + +void array() { + int a[(1 + 1 == 2) * 2]; +} + +void local_decl() { + int y = y; + { + int x = x; + int a; + int b = a = 2; + } +} + +struct Node n; +struct Node {int x, y;} n; +/* global forward declaration is ok */ +int again; +int again; + +typedef int def; +int typedef1() { + int def; /* overrides outer typedef */ + def = 1; +} +typedef int *ptr1; +int typedef2() { + typedef int **ptr2; + { + typedef int ***ptr3; + ptr3 ptr2; + ptr3 ptr1; + } +} + +typedef struct TA { + int x; +} TA; +typedef struct TA TA; +int typedef_struct() { + TA a; + a.x = 1; +} + +struct AA {int x; int y; }; +int aa(struct AA {int a;} p) { + struct AA a; + a.a; +} + +int main() { + int self = sizeof self; + n.x = 1; + n.y = 2; +} diff --git a/semantics_data/ref.c b/semantics_data/ref.c new file mode 100644 index 0000000..4644127 --- /dev/null +++ b/semantics_data/ref.c @@ -0,0 +1,4 @@ +int main() { + int a, b; + &(a + b); +} diff --git a/semantics_data/sizeof.c b/semantics_data/sizeof.c new file mode 100644 index 0000000..4d0dceb --- /dev/null +++ b/semantics_data/sizeof.c @@ -0,0 +1,3 @@ +int main() { + int a[sizeof a]; +} diff --git a/semantics_data/typedef1.c b/semantics_data/typedef1.c new file mode 100644 index 0000000..e67c112 --- /dev/null +++ b/semantics_data/typedef1.c @@ -0,0 +1,4 @@ +int main() { + typedef int a; + int a(); +} diff --git a/semantics_data/typedef2.c b/semantics_data/typedef2.c new file mode 100644 index 0000000..be9f3a4 --- /dev/null +++ b/semantics_data/typedef2.c @@ -0,0 +1,4 @@ +int main() { + typedef int a; +} +int a; diff --git a/semantics_data/typedef3.c b/semantics_data/typedef3.c new file mode 100644 index 0000000..71c45d1 --- /dev/null +++ b/semantics_data/typedef3.c @@ -0,0 +1,4 @@ +typedef int a; +int main() { +} +int a; diff --git a/semantics_data/typedef4.c b/semantics_data/typedef4.c new file mode 100644 index 0000000..0aeb0f4 --- /dev/null +++ b/semantics_data/typedef4.c @@ -0,0 +1,10 @@ +typedef struct I I; +int incomp(I a); +struct I { int i, j; }; +int incomp(I a) {} +typedef int b; +int main() { + I i; + b b; + incomp(i); +} diff --git a/semantics_data/void_decl.c b/semantics_data/void_decl.c new file mode 100644 index 0000000..8a68b18 --- /dev/null +++ b/semantics_data/void_decl.c @@ -0,0 +1,3 @@ +void a; +int main() { +} diff --git a/semantics_data/void_decl2.c b/semantics_data/void_decl2.c new file mode 100644 index 0000000..30c7af6 --- /dev/null +++ b/semantics_data/void_decl2.c @@ -0,0 +1,5 @@ +struct { + void a; +}; +int main() { +} diff --git a/test_all.sh b/test_all.sh deleted file mode 100755 index 03ff5d0..0000000 --- a/test_all.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/bash -dir=testcases/*.c -if [ "$#" != 0 ]; then - dir=$1 -fi -res=0 -for file in $dir -do - gcc $file -o /dev/null &> /dev/null - gcc_ret="$?" - ./cibic $file &> /dev/null - ret=$? - if [ $ret -ne $gcc_ret ]; then - echo "Failed on $file" - res=1 - else - echo "ok $file: $ret" - fi -done -exit $res diff --git a/test_compile.sh b/test_compile.sh new file mode 100755 index 0000000..073231c --- /dev/null +++ b/test_compile.sh @@ -0,0 +1,18 @@ +#! /bin/bash +cp cibic compile_data/ +cp lib.s compile_data/ +cd compile_data/ +for f in *.c +do + echo $f + ./cibic $f > mips.s 2> /dev/null + gcc $f -m32 -std=c99 2> /dev/null + ./spim -stat -file mips.s > out + ./a.out > std + diff std out + if [[ "$?" != 0 ]]; then + echo "Wrong Answer!" + break; + fi +done +echo "OK." diff --git a/test_semantics.sh b/test_semantics.sh new file mode 100755 index 0000000..c84fc2a --- /dev/null +++ b/test_semantics.sh @@ -0,0 +1,20 @@ +#! /bin/bash +dir=semantics_data/*.c +if [ "$#" != 0 ]; then + dir=$1 +fi +res=0 +for file in $dir +do + gcc $file -o /dev/null &> /dev/null + gcc_ret="$?" + ./cibic $file &> /dev/null + ret=$? + if [ $ret -ne $gcc_ret ]; then + echo "Failed on $file" + res=1 + else + echo "ok $file: $ret" + fi +done +exit $res diff --git a/testbed/custom_const.c b/testbed/custom_const.c deleted file mode 100644 index d0126f3..0000000 --- a/testbed/custom_const.c +++ /dev/null @@ -1,9 +0,0 @@ -int sum; -void f() { - sum = 3; -} -int main() { - sum = 1; - f(); - printf("%d\n", sum); -} diff --git a/testbed/custom_struct.c b/testbed/custom_struct.c deleted file mode 100644 index 0d473f5..0000000 --- a/testbed/custom_struct.c +++ /dev/null @@ -1,26 +0,0 @@ -struct D { - int a, b; -}; -struct A { - int a[100]; - struct B { - struct C { - int x, y; - } c; - int z; - struct D *p; - } b; -} s; -int main() { - struct D d; - int n = 0; - s.a[1] = 1; - s.a[2] = 2; - s.b.z = 4; - s.b.c.x = 5; - s.b.c.y = 6; - s.b.p = &d; - s.b.p->a = 7; - s.b.p->b = 8; - printf("%d %d %d %d %d %d %d\n", s.a[1], s.a[2], s.b.z, s.b.c.x, s.b.c.y, s.b.p->a, s.b.p->b); -} diff --git a/testbed/custom_struct2.c b/testbed/custom_struct2.c deleted file mode 100644 index e147186..0000000 --- a/testbed/custom_struct2.c +++ /dev/null @@ -1,41 +0,0 @@ -struct A { - int x, y; -} sa; -struct A print(struct A a, struct A b) { - a.x++; - a.y++; - b.x--; - b.y--; - printf("args: %d %d\n", a.x, a.y); - printf("args: %d %d\n", b.x, b.y); - return a; -} -int main() { - int i; - int t; - int *a, *b; - struct A sb, sc; - a = malloc(sizeof(int) * 100); - for (i = 0; i < 100; i++) - a[i] = i; - b = malloc(sizeof(int) * 100); - memcpy(b, a, sizeof(int) * 100); - for (i = 0; i < 100; i++) - printf("%d ", b[i]); - sb.x = 1; - sb.y = 2; - sa = sb; - sc = sa; - printf("\n%d %d\n", sa.x, sa.y); - printf("%d %d\n", sc.x, sc.y); - sa.x = 1; - sa.y = 2; - sb.x = 1; - sb.y = 2; - sa = print(sa, sb); - sb = print(sa, sb); - sa = print(sa, sb); - sb = print(sa, sb); - printf("%d %d\n", sa.x, sa.y); - printf("%d %d\n", sb.x, sb.y); -} diff --git a/testbed/custom_struct3.c b/testbed/custom_struct3.c deleted file mode 100644 index d7060b3..0000000 --- a/testbed/custom_struct3.c +++ /dev/null @@ -1,15 +0,0 @@ -struct A { - int x, y; -} a[10]; -struct A f(struct A a) { - a.x++; - a.y++; - return a; -} -int main(){ - int i; - for (i = 1; i < 10; i++) - a[i] = f(a[i - 1]); - for (i = 0; i < 10; i++) - printf("%d %d\n", a[i].x, a[i].y); -} diff --git a/testbed/custom_struct4.c b/testbed/custom_struct4.c deleted file mode 100644 index 75f50ea..0000000 --- a/testbed/custom_struct4.c +++ /dev/null @@ -1,28 +0,0 @@ -struct A { - struct B { - int x, y; - struct C { - int w; - } c; - } b; - int z; -}; - -struct B f(struct A a) { - printf("z: %d\n", a.z); - return a.b; -} - -struct C g(struct B b) { - printf("x: %d\ny: %d\n", b.x, b.y); - return b.c; -} - -int main() { - struct A a; - a.z = 1; - a.b.x = 2; - a.b.y = 3; - a.b.c.w = 4; - printf("w: %d\n", g(f(a)).w); -} diff --git a/testbed/custom_subexp.c b/testbed/custom_subexp.c deleted file mode 100644 index bce5bdb..0000000 --- a/testbed/custom_subexp.c +++ /dev/null @@ -1,9 +0,0 @@ -int N = 0; -void f() { N = 2; } -int main() { - int a, b; - a = N + 1; - f(); - b = N + 1; - printf("%d\n", b); -} diff --git a/testbed/custom_subexp2.c b/testbed/custom_subexp2.c deleted file mode 100644 index 1e4af93..0000000 --- a/testbed/custom_subexp2.c +++ /dev/null @@ -1,10 +0,0 @@ -int flag = 0; -int check(int x, int y) { - return x > 0 && y > 0 && (flag ^= 1); -} -int main() { - int x = 1, y = 2; - printf("%d\n", check(x, y)); - printf("%d\n", check(x, y)); - printf("%d\n", check(x, y)); -} diff --git a/testbed/func_pointer.c b/testbed/func_pointer.c deleted file mode 100644 index e7b6484..0000000 --- a/testbed/func_pointer.c +++ /dev/null @@ -1,19 +0,0 @@ -typedef void (*Func_t)(); -void f(Func_t func, int step) { - if (!step) return; - printf("i'm f\n"); - func(func, step - 1); -} -void g(void (*func)(), int step) { - if (!step) return; - printf("i'm g\n"); - func(func, step - 1); -} -int main() { - void (*func)(void (*ifunc)(), int step); - int x = 1; - if (x) func = f; - else func = g; - func(func, 5); - return 0; -} diff --git a/testcases/anonymous_struct1.c b/testcases/anonymous_struct1.c deleted file mode 100644 index 2709f70..0000000 --- a/testcases/anonymous_struct1.c +++ /dev/null @@ -1,6 +0,0 @@ -int main() { - struct {int x, y;} a, b, c; - a = b; - b = c; - c = a; -} diff --git a/testcases/anonymous_struct2.c b/testcases/anonymous_struct2.c deleted file mode 100644 index b17e6c0..0000000 --- a/testcases/anonymous_struct2.c +++ /dev/null @@ -1,7 +0,0 @@ -int main() { - struct {int x, y;} a; - struct {int x, y;} b, c; - a = b; - b = c; - c = a; -} diff --git a/testcases/array_complete.c b/testcases/array_complete.c deleted file mode 100644 index 79c5c8a..0000000 --- a/testcases/array_complete.c +++ /dev/null @@ -1,4 +0,0 @@ -struct A arr[1]; -struct A {int x;}; -int main() { -} diff --git a/testcases/array_decl.c b/testcases/array_decl.c deleted file mode 100644 index 33973e5..0000000 --- a/testcases/array_decl.c +++ /dev/null @@ -1,6 +0,0 @@ -int f(int a[1][3][2]) { -} -int main() { - int a[3][3][2]; - f(a); -} diff --git a/testcases/array_decl2.c b/testcases/array_decl2.c deleted file mode 100644 index d7f8a04..0000000 --- a/testcases/array_decl2.c +++ /dev/null @@ -1,7 +0,0 @@ -int f(int a[20][2][2]); -int f(int a[1][3][2]) { -} -int main() { - int a[3][3][2]; - f(a); -} diff --git a/testcases/cast.c b/testcases/cast.c deleted file mode 100644 index b441552..0000000 --- a/testcases/cast.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - ((int (*)(int a))1)(1); -} diff --git a/testcases/cast2.c b/testcases/cast2.c deleted file mode 100644 index 34b3484..0000000 --- a/testcases/cast2.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - (int [3])1; -} diff --git a/testcases/cast3.c b/testcases/cast3.c deleted file mode 100644 index 4500cb1..0000000 --- a/testcases/cast3.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - (int ())1; -} diff --git a/testcases/conflict.c b/testcases/conflict.c deleted file mode 100644 index f2798e7..0000000 --- a/testcases/conflict.c +++ /dev/null @@ -1,4 +0,0 @@ -int f(int a, char b); -int f(int a); -int main() { -} diff --git a/testcases/decl_comp.c b/testcases/decl_comp.c deleted file mode 100644 index f1b8bd2..0000000 --- a/testcases/decl_comp.c +++ /dev/null @@ -1,5 +0,0 @@ -int f(); -int f(int a); -int main() { - f(1, 2); -} diff --git a/testcases/decl_comp2.c b/testcases/decl_comp2.c deleted file mode 100644 index f1298bd..0000000 --- a/testcases/decl_comp2.c +++ /dev/null @@ -1,5 +0,0 @@ -int f(int a); -int f() { -} -int main() { -} diff --git a/testcases/decl_comp3.c b/testcases/decl_comp3.c deleted file mode 100644 index 29d388f..0000000 --- a/testcases/decl_comp3.c +++ /dev/null @@ -1,4 +0,0 @@ -int f(); -int f(int a) { - f(); -} diff --git a/testcases/fail1.c b/testcases/fail1.c deleted file mode 100644 index f80ecaa..0000000 --- a/testcases/fail1.c +++ /dev/null @@ -1,2 +0,0 @@ -int main(struct C c) { /* fail because of incomplete type of parameter */ -} diff --git a/testcases/fail10.c b/testcases/fail10.c deleted file mode 100644 index e287c6f..0000000 --- a/testcases/fail10.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - int a[2][3]; - a[1][3][3] = 3; -} diff --git a/testcases/fail11.c b/testcases/fail11.c deleted file mode 100644 index 4aa213a..0000000 --- a/testcases/fail11.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - int a[2][3]; - a[1] = 3; -} diff --git a/testcases/fail2.c b/testcases/fail2.c deleted file mode 100644 index a76d4e0..0000000 --- a/testcases/fail2.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - /* fail because of incomplete type of local variable */ - struct C c; -} diff --git a/testcases/fail3.c b/testcases/fail3.c deleted file mode 100644 index ad47f5f..0000000 --- a/testcases/fail3.c +++ /dev/null @@ -1,4 +0,0 @@ -int main(int main) { - /* fail because `f' is overrided by parameter */ - main(3); -} diff --git a/testcases/fail4.c b/testcases/fail4.c deleted file mode 100644 index 20033af..0000000 --- a/testcases/fail4.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - (void)1 + 2; /* not ok */ -} diff --git a/testcases/fail5.c b/testcases/fail5.c deleted file mode 100644 index 0e8fba8..0000000 --- a/testcases/fail5.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - /* fail because of incomplete field */ - struct C {struct B b;} *c; -} diff --git a/testcases/fail6.c b/testcases/fail6.c deleted file mode 100644 index 3419ce9..0000000 --- a/testcases/fail6.c +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 5040408..0000000 --- a/testcases/fail7.c +++ /dev/null @@ -1,6 +0,0 @@ -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/fail8.c b/testcases/fail8.c deleted file mode 100644 index 21efd5f..0000000 --- a/testcases/fail8.c +++ /dev/null @@ -1,5 +0,0 @@ -struct { - int f(); -}; -int main() { -} diff --git a/testcases/function_returns_function.c b/testcases/function_returns_function.c deleted file mode 100644 index e590ddb..0000000 --- a/testcases/function_returns_function.c +++ /dev/null @@ -1 +0,0 @@ -int main()() {} diff --git a/testcases/global_decl.c b/testcases/global_decl.c deleted file mode 100644 index ff49829..0000000 --- a/testcases/global_decl.c +++ /dev/null @@ -1,3 +0,0 @@ -int x = x; -int main() { -} diff --git a/testcases/incomp_initr.c b/testcases/incomp_initr.c deleted file mode 100644 index 1068284..0000000 --- a/testcases/incomp_initr.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - struct A {int x, y;} b; - int a[(1 + 1 == 2) * 2] = {1, b}; -} diff --git a/testcases/incomp_param.c b/testcases/incomp_param.c deleted file mode 100644 index c1ece5f..0000000 --- a/testcases/incomp_param.c +++ /dev/null @@ -1,5 +0,0 @@ -int f(struct A a, int b) { - -} -int main() { -} diff --git a/testcases/local_struct.c b/testcases/local_struct.c deleted file mode 100644 index 28cb223..0000000 --- a/testcases/local_struct.c +++ /dev/null @@ -1,7 +0,0 @@ -struct A {int x; int y; } b; -int f(struct A {int a;} p) { - struct A a; - a.x; -} -int main() { -} diff --git a/testcases/param1.c b/testcases/param1.c deleted file mode 100644 index 6c22a2b..0000000 --- a/testcases/param1.c +++ /dev/null @@ -1,5 +0,0 @@ -int f(); -int f() {} -int main() { - f(1, 2, 3); -} diff --git a/testcases/param2.c b/testcases/param2.c deleted file mode 100644 index 6b1726d..0000000 --- a/testcases/param2.c +++ /dev/null @@ -1,4 +0,0 @@ -int f(); -int f(int a) {} -int main() { -} diff --git a/testcases/param3.c b/testcases/param3.c deleted file mode 100644 index 8492455..0000000 --- a/testcases/param3.c +++ /dev/null @@ -1,4 +0,0 @@ -int f(int a); -int f() {} -int main() { -} diff --git a/testcases/pass.c b/testcases/pass.c deleted file mode 100644 index a7d4481..0000000 --- a/testcases/pass.c +++ /dev/null @@ -1,147 +0,0 @@ -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; -} - -int complex_pointer() { - int (*g(int ***e[10]))(); -} - -int fp(int a, int b, int c) { - int (*f)(int a, int b, int c); - f = ****fp + 1; - (****f)(1, 2, 3); - f = &fp + 1; -} - -int fc(int fc()) { - fc(complex_pointer); -} - -int incomp(struct I a); -struct I { int i, j; }; - -void (*bsd_signal(int sig, void (*func)(int a)))(int b); - -void array() { - int a[(1 + 1 == 2) * 2]; -} - -void local_decl() { - int y = y; - { - int x = x; - int a; - int b = a = 2; - } -} - -struct Node n; -struct Node {int x, y;} n; -/* global forward declaration is ok */ -int again; -int again; - -typedef int def; -int typedef1() { - int def; /* overrides outer typedef */ - def = 1; -} -typedef int *ptr1; -int typedef2() { - typedef int **ptr2; - { - typedef int ***ptr3; - ptr3 ptr2; - ptr3 ptr1; - } -} - -typedef struct TA { - int x; -} TA; -typedef struct TA TA; -int typedef_struct() { - TA a; - a.x = 1; -} - -struct AA {int x; int y; }; -int aa(struct AA {int a;} p) { - struct AA a; - a.a; -} - -int main() { - int self = sizeof self; - n.x = 1; - n.y = 2; -} diff --git a/testcases/ref.c b/testcases/ref.c deleted file mode 100644 index 4644127..0000000 --- a/testcases/ref.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - int a, b; - &(a + b); -} diff --git a/testcases/sizeof.c b/testcases/sizeof.c deleted file mode 100644 index 4d0dceb..0000000 --- a/testcases/sizeof.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - int a[sizeof a]; -} diff --git a/testcases/typedef1.c b/testcases/typedef1.c deleted file mode 100644 index e67c112..0000000 --- a/testcases/typedef1.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - typedef int a; - int a(); -} diff --git a/testcases/typedef2.c b/testcases/typedef2.c deleted file mode 100644 index be9f3a4..0000000 --- a/testcases/typedef2.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - typedef int a; -} -int a; diff --git a/testcases/typedef3.c b/testcases/typedef3.c deleted file mode 100644 index 71c45d1..0000000 --- a/testcases/typedef3.c +++ /dev/null @@ -1,4 +0,0 @@ -typedef int a; -int main() { -} -int a; diff --git a/testcases/typedef4.c b/testcases/typedef4.c deleted file mode 100644 index 0aeb0f4..0000000 --- a/testcases/typedef4.c +++ /dev/null @@ -1,10 +0,0 @@ -typedef struct I I; -int incomp(I a); -struct I { int i, j; }; -int incomp(I a) {} -typedef int b; -int main() { - I i; - b b; - incomp(i); -} diff --git a/testcases/void_decl.c b/testcases/void_decl.c deleted file mode 100644 index 8a68b18..0000000 --- a/testcases/void_decl.c +++ /dev/null @@ -1,3 +0,0 @@ -void a; -int main() { -} diff --git a/testcases/void_decl2.c b/testcases/void_decl2.c deleted file mode 100644 index 30c7af6..0000000 --- a/testcases/void_decl2.c +++ /dev/null @@ -1,5 +0,0 @@ -struct { - void a; -}; -int main() { -} -- cgit v1.2.3-70-g09d2