aboutsummaryrefslogtreecommitdiff
path: root/semantics_data
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-05-07 03:17:32 +0800
committerTeddy <[email protected]>2014-05-07 03:17:32 +0800
commit52b29440f8f1310e0c074c8eb409e433c56bdd62 (patch)
tree6d91ceeb6594fe337541ed3f9f50cd33ee8881ca /semantics_data
parent0ac22f0214ee283ce9bb053d691aeac823f875be (diff)
rename
Diffstat (limited to 'semantics_data')
-rw-r--r--semantics_data/anonymous_struct1.c6
-rw-r--r--semantics_data/anonymous_struct2.c7
-rw-r--r--semantics_data/array_complete.c4
-rw-r--r--semantics_data/array_decl.c6
-rw-r--r--semantics_data/array_decl2.c7
-rw-r--r--semantics_data/cast.c3
-rw-r--r--semantics_data/cast2.c3
-rw-r--r--semantics_data/cast3.c3
-rw-r--r--semantics_data/conflict.c4
-rw-r--r--semantics_data/decl_comp.c5
-rw-r--r--semantics_data/decl_comp2.c5
-rw-r--r--semantics_data/decl_comp3.c4
-rw-r--r--semantics_data/fail1.c2
-rw-r--r--semantics_data/fail10.c4
-rw-r--r--semantics_data/fail11.c4
-rw-r--r--semantics_data/fail2.c4
-rw-r--r--semantics_data/fail3.c4
-rw-r--r--semantics_data/fail4.c3
-rw-r--r--semantics_data/fail5.c4
-rw-r--r--semantics_data/fail6.c5
-rw-r--r--semantics_data/fail7.c6
-rw-r--r--semantics_data/fail8.c5
-rw-r--r--semantics_data/function_returns_function.c1
-rw-r--r--semantics_data/global_decl.c3
-rw-r--r--semantics_data/incomp_initr.c4
-rw-r--r--semantics_data/incomp_param.c5
-rw-r--r--semantics_data/local_struct.c7
-rw-r--r--semantics_data/param1.c5
-rw-r--r--semantics_data/param2.c4
-rw-r--r--semantics_data/param3.c4
-rw-r--r--semantics_data/pass.c147
-rw-r--r--semantics_data/ref.c4
-rw-r--r--semantics_data/sizeof.c3
-rw-r--r--semantics_data/typedef1.c4
-rw-r--r--semantics_data/typedef2.c4
-rw-r--r--semantics_data/typedef3.c4
-rw-r--r--semantics_data/typedef4.c10
-rw-r--r--semantics_data/void_decl.c3
-rw-r--r--semantics_data/void_decl2.c5
39 files changed, 315 insertions, 0 deletions
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() {
+}