[hackers] [scc] [test] Import new tests from Andrew Chambers || Roberto E. Vargas Caballero
commit 818531121a8b011fd6a977e6d5751b892063f187
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 12 11:56:33 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Jan 12 11:56:33 2017 +0100
[test] Import new tests from Andrew Chambers
diff --git a/tests/0082-bug.c b/tests/0082-bug.c
new file mode 100644
index 0000000..ad0af76
--- /dev/null
+++ b/tests/0082-bug.c
_AT_@ -0,0 +1,17 @@
+#define x(y) ((y) + 1)
+
+int
+main()
+{
+ int x;
+ int y;
+
+ y = 0;
+ x = x(y);
+
+ if(x != 1)
+ return 1;
+
+ return 0;
+}
+
diff --git a/tests/0083-voidret.c b/tests/0083-voidret.c
new file mode 100644
index 0000000..e2c4ff4
--- /dev/null
+++ b/tests/0083-voidret.c
_AT_@ -0,0 +1,13 @@
+
+void
+voidfn()
+{
+ return;
+}
+
+int
+main()
+{
+ voidfn();
+ return 0;
+}
diff --git a/tests/0084-longlong.c b/tests/0084-longlong.c
new file mode 100644
index 0000000..a2b8580
--- /dev/null
+++ b/tests/0084-longlong.c
_AT_@ -0,0 +1,12 @@
+
+int
+main()
+{
+ long long x;
+
+ x = 0;
+ x = x + 1;
+ if (x != 1)
+ return 1;
+ return 0;
+}
diff --git a/tests/0085-ulonglong.c b/tests/0085-ulonglong.c
new file mode 100644
index 0000000..dc3e356
--- /dev/null
+++ b/tests/0085-ulonglong.c
_AT_@ -0,0 +1,12 @@
+
+int
+main()
+{
+ unsigned long long x;
+
+ x = 0;
+ x = x + 1;
+ if (x != 1)
+ return 1;
+ return 0;
+}
diff --git a/tests/0086-variadic.c b/tests/0086-variadic.c
new file mode 100644
index 0000000..cb05002
--- /dev/null
+++ b/tests/0086-variadic.c
_AT_@ -0,0 +1,55 @@
+#define CALL(FUN, ...) FUN(__VA_ARGS__)
+
+int
+none()
+{
+ return 0;
+}
+
+int
+one(int a)
+{
+ if (a != 1)
+ return 1;
+
+ return 0;
+}
+
+int
+two(int a, int b)
+{
+ if (a != 1)
+ return 1;
+ if (b != 2)
+ return 1;
+
+ return 0;
+}
+
+int
+three(int a, int b, int c)
+{
+ if (a != 1)
+ return 1;
+ if (b != 2)
+ return 1;
+ if (c != 3)
+ return 1;
+
+ return 0;
+}
+
+int
+main()
+{
+ if (CALL(none))
+ return 1;
+ if (CALL(one, 1))
+ return 2;
+ if (CALL(two, 1, 2))
+ return 3;
+ if (CALL(three, 1, 2, 3))
+ return 4;
+
+ return 0;
+}
diff --git a/tests/0087-variadic.c b/tests/0087-variadic.c
new file mode 100644
index 0000000..cfd0fac
--- /dev/null
+++ b/tests/0087-variadic.c
_AT_@ -0,0 +1,54 @@
+#define ARGS(...) __VA_ARGS__
+
+int
+none()
+{
+ return 0;
+}
+
+int
+one(int a)
+{
+ if (a != 1)
+ return 1;
+
+ return 0;
+}
+
+int
+two(int a, int b)
+{
+ if (a != 1)
+ return 1;
+ if (b != 2)
+ return 1;
+
+ return 0;
+}
+
+int
+three(int a, int b, int c)
+{
+ if (a != 1)
+ return 1;
+ if (b != 2)
+ return 1;
+ if (c != 3)
+ return 1;
+
+ return 0;
+}
+
+int
+main()
+{
+ if (none(ARGS()))
+ return 1;
+ if (one(ARGS(1)))
+ return 2;
+ if (two(ARGS(1, 2)))
+ return 3;
+ if (three(ARGS(1, 2, 3)))
+ return 4;
+ return 0;
+}
diff --git a/tests/0088-macros.c b/tests/0088-macros.c
new file mode 100644
index 0000000..65d678b
--- /dev/null
+++ b/tests/0088-macros.c
_AT_@ -0,0 +1,30 @@
+#define ZERO_0() 0
+#define ZERO_1(A) 0
+#define ZERO_2(A, B) 0
+#define ZERO_VAR(...) 0
+#define ZERO_1_VAR(A, ...) 0
+
+int
+main()
+{
+ if (ZERO_0())
+ return 1;
+ if (ZERO_1(1))
+ return 1;
+ if (ZERO_2(1, 2))
+ return 1;
+ if (ZERO_VAR())
+ return 1;
+ if (ZERO_VAR(1))
+ return 1;
+ if (ZERO_VAR(1, 2))
+ return 1;
+ if (ZERO_1_VAR(1))
+ return 1;
+ if (ZERO_1_VAR(1, 2))
+ return 1;
+ if (ZERO_1_VAR(1, 2, 3))
+ return 1;
+
+ return 0;
+}
diff --git a/tests/0089-short.c b/tests/0089-short.c
new file mode 100644
index 0000000..4dce16f
--- /dev/null
+++ b/tests/0089-short.c
_AT_@ -0,0 +1,12 @@
+
+int
+main()
+{
+ short x;
+
+ x = 0;
+ x = x + 1;
+ if (x != 1)
+ return 1;
+ return 0;
+}
diff --git a/tests/0090-fptr.c b/tests/0090-fptr.c
new file mode 100644
index 0000000..e30edfa
--- /dev/null
+++ b/tests/0090-fptr.c
_AT_@ -0,0 +1,21 @@
+
+struct S
+{
+ int (*fptr)();
+};
+
+int
+foo()
+{
+ return 0;
+}
+
+int
+main()
+{
+ struct S v;
+
+ v.fptr = foo;
+ return v.fptr();
+}
+
diff --git a/tests/0091-fptr.c b/tests/0091-fptr.c
new file mode 100644
index 0000000..f0cf00f
--- /dev/null
+++ b/tests/0091-fptr.c
_AT_@ -0,0 +1,12 @@
+
+int (*fptr)() = 0;
+
+
+int
+main()
+{
+ if (fptr)
+ return 1;
+ return 0;
+}
+
diff --git a/tests/0092-fptr.c b/tests/0092-fptr.c
new file mode 100644
index 0000000..ab6b5ef
--- /dev/null
+++ b/tests/0092-fptr.c
_AT_@ -0,0 +1,31 @@
+
+int
+zero()
+{
+ return 0;
+}
+
+struct S
+{
+ int (*zerofunc)();
+} s = { &zero };
+
+struct S *
+anon()
+{
+ return &s;
+}
+
+typedef struct S * (*fty)();
+
+fty
+go()
+{
+ return &anon;
+}
+
+int
+main()
+{
+ return go()()->zerofunc();
+}
diff --git a/tests/0093-arrayinit.c b/tests/0093-arrayinit.c
new file mode 100644
index 0000000..21f7118
--- /dev/null
+++ b/tests/0093-arrayinit.c
_AT_@ -0,0 +1,15 @@
+
+int a[3] = {0, 1, 2};
+
+int
+main()
+{
+ if (a[0] != 0)
+ return 1;
+ if (a[1] != 1)
+ return 2;
+ if (a[2] != 2)
+ return 3;
+
+ return 0;
+}
diff --git a/tests/0094-arrayinit.c b/tests/0094-arrayinit.c
new file mode 100644
index 0000000..e90d5f3
--- /dev/null
+++ b/tests/0094-arrayinit.c
_AT_@ -0,0 +1,20 @@
+
+typedef struct {
+ int v;
+ int sub[2];
+} S;
+
+S a[1] = {{1, {2, 3}}};
+
+int
+main()
+{
+ if (a[0].v != 1)
+ return 1;
+ if (a[0].sub[0] != 2)
+ return 2;
+ if (a[0].sub[1] != 3)
+ return 3;
+
+ return 0;
+}
diff --git a/tests/0095-arrayselector.c b/tests/0095-arrayselector.c
new file mode 100644
index 0000000..19341f2
--- /dev/null
+++ b/tests/0095-arrayselector.c
_AT_@ -0,0 +1,23 @@
+
+
+
+
+int a[] = {5, [2] = 2, 3};
+
+int
+main()
+{
+ if (sizeof(a) != 4*sizeof(int))
+ return 1;
+
+ if (a[0] != 5)
+ return 2;
+ if (a[1] != 0)
+ return 3;
+ if (a[2] != 2)
+ return 4;
+ if (a[3] != 3)
+ return 5;
+
+ return 0;
+}
diff --git a/tests/0096-inferredarraysize.c b/tests/0096-inferredarraysize.c
new file mode 100644
index 0000000..31758d8
--- /dev/null
+++ b/tests/0096-inferredarraysize.c
_AT_@ -0,0 +1,12 @@
+
+
+int a[] = {1, 2, 3, 4};
+
+int
+main()
+{
+ if (sizeof(a) != 4*sizeof(int))
+ return 1;
+
+ return 0;
+}
diff --git a/tests/0097-extern.c b/tests/0097-extern.c
new file mode 100644
index 0000000..b71ada8
--- /dev/null
+++ b/tests/0097-extern.c
_AT_@ -0,0 +1,6 @@
+extern int x;
+
+int main()
+{
+ return 0;
+}
diff --git a/tests/0098-tentative.c b/tests/0098-tentative.c
new file mode 100644
index 0000000..1184b85
--- /dev/null
+++ b/tests/0098-tentative.c
_AT_@ -0,0 +1,23 @@
+
+int x;
+int x = 3;
+int x;
+
+int main();
+
+void *
+foo()
+{
+ return &main;
+}
+
+int
+main()
+{
+ if (x != 3)
+ return 0;
+
+ x = 0;
+ return x;
+}
+
diff --git a/tests/0099-tentative.c b/tests/0099-tentative.c
new file mode 100644
index 0000000..37165a8
--- /dev/null
+++ b/tests/0099-tentative.c
_AT_@ -0,0 +1,13 @@
+
+int x, x = 3, x;
+
+int
+main()
+{
+ if (x != 3)
+ return 0;
+
+ x = 0;
+ return x;
+}
+
diff --git a/tests/0100-redeclaremacro.c b/tests/0100-redeclaremacro.c
new file mode 100644
index 0000000..cf94041
--- /dev/null
+++ b/tests/0100-redeclaremacro.c
_AT_@ -0,0 +1,15 @@
+
+#define NULL ((void*)0)
+#define NULL ((void*)0)
+
+#define FOO(X, Y) (X + Y + Z)
+#define FOO(X, Y) (X + Y + Z)
+
+#define BAR(X, Y, ...) (X + Y + Z)
+#define BAR(X, Y, ...) (X + Y + Z)
+
+int
+main()
+{
+ return 0;
+}
diff --git a/tests/0101-wcharlit.c b/tests/0101-wcharlit.c
new file mode 100644
index 0000000..194db7b
--- /dev/null
+++ b/tests/0101-wcharlit.c
_AT_@ -0,0 +1,6 @@
+
+int
+main()
+{
+ return L'\0';
+}
diff --git a/tests/0102-bug.c b/tests/0102-bug.c
new file mode 100644
index 0000000..06c77bd
--- /dev/null
+++ b/tests/0102-bug.c
_AT_@ -0,0 +1,14 @@
+// This wouldn't compile
+
+typedef struct { } Vec;
+
+static void
+vecresize(Vec *v, int cap)
+{
+ return;
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/tests/0103-voidparm.c b/tests/0103-voidparm.c
new file mode 100644
index 0000000..c67452a
--- /dev/null
+++ b/tests/0103-voidparm.c
_AT_@ -0,0 +1,12 @@
+
+int
+foo(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ return foo();
+}
diff --git a/tests/0104-voidparm.c b/tests/0104-voidparm.c
new file mode 100644
index 0000000..633b86f
--- /dev/null
+++ b/tests/0104-voidparm.c
_AT_@ -0,0 +1,11 @@
+
+int
+main()
+{
+ int c;
+ c = 0;
+ do
+ ;
+ while (0);
+ return c;
+}
diff --git a/tests/0105-shl.c b/tests/0105-shl.c
new file mode 100644
index 0000000..53c2faf
--- /dev/null
+++ b/tests/0105-shl.c
_AT_@ -0,0 +1,12 @@
+
+int
+main()
+{
+ int x;
+
+ x = 1;
+ if ((x << 1) != 2)
+ return 1;
+
+ return 0;
+}
diff --git a/tests/0106-ppcast.c b/tests/0106-ppcast.c
new file mode 100644
index 0000000..9fc1478
--- /dev/null
+++ b/tests/0106-ppcast.c
_AT_@ -0,0 +1,15 @@
+
+int
+main()
+{
+ int x;
+ void *foo;
+ void **bar;
+
+ x = 0;
+
+ foo = (void*)&x;
+ bar = &foo;
+
+ return **(int**)bar;
+}
diff --git a/tests/0107-bnot.c b/tests/0107-bnot.c
new file mode 100644
index 0000000..464e7f2
--- /dev/null
+++ b/tests/0107-bnot.c
_AT_@ -0,0 +1,22 @@
+
+
+int
+main()
+{
+ int x;
+ long long l;
+
+ x = 0;
+ l = 0;
+
+ x = ~x;
+ if (x != 0xffffffff)
+ return 1;
+
+ l = ~l;
+ if (x != 0xffffffffffffffff)
+ return 2;
+
+
+ return 0;
+}
diff --git a/tests/0108-bug.c b/tests/0108-bug.c
new file mode 100644
index 0000000..34d9f97
--- /dev/null
+++ b/tests/0108-bug.c
_AT_@ -0,0 +1,13 @@
+
+
+int
+main()
+{
+ int i;
+
+ for(i = 0; i < 10; i++)
+ if (!i)
+ continue;
+
+ return 0;
+}
diff --git a/tests/scc-tests.lst b/tests/scc-tests.lst
index 9728e79..641ebf4 100644
--- a/tests/scc-tests.lst
+++ b/tests/scc-tests.lst
_AT_@ -77,3 +77,25 @@
0079-cond.c
0080-arrays.c
0081-calls.c
+0082-bug.c
+0083-voidret.c
+0084-longlong.c
+0085-ulonglong.c
+0089-short.c
+0090-fptr.c
+0091-fptr.c
+0092-fptr.c
+0093-arrayinit.c
+0094-arrayinit.c
+0095-arrayselector.c
+0096-inferredarraysize.c
+0097-extern.c
+0098-tentative.c
+0099-tentative.c
+0102-bug.c
+0103-voidparm.c
+0104-voidparm.c
+0105-shl.c
+0106-ppcast.c
+0107-bnot.c
+0108-bug.c
Received on Thu Jan 12 2017 - 11:57:36 CET
This archive was generated by hypermail 2.3.0
: Thu Jan 12 2017 - 12:00:11 CET