shithub: scc

Download patch

ref: 9e3a6f8d81f93d96138d8a664b4b592518ca9854
parent: b2d10b743a716ae76c3f0f11937c6d84f64668fe
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 12 06:56:33 EST 2017

[test] Import new tests from Andrew Chambers

--- /dev/null
+++ b/tests/0082-bug.c
@@ -1,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;
+}
+
--- /dev/null
+++ b/tests/0083-voidret.c
@@ -1,0 +1,13 @@
+
+void
+voidfn()
+{
+    return;
+}
+
+int
+main()
+{
+    voidfn();
+    return 0;
+}
--- /dev/null
+++ b/tests/0084-longlong.c
@@ -1,0 +1,12 @@
+
+int
+main()
+{
+	long long x;
+	
+	x = 0;
+	x = x + 1;
+	if (x != 1)
+		return 1;
+	return 0;
+}
--- /dev/null
+++ b/tests/0085-ulonglong.c
@@ -1,0 +1,12 @@
+
+int
+main()
+{
+	unsigned long long x;
+	
+	x = 0;
+	x = x + 1;
+	if (x != 1)
+		return 1;
+	return 0;
+}
--- /dev/null
+++ b/tests/0086-variadic.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0087-variadic.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0088-macros.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0089-short.c
@@ -1,0 +1,12 @@
+
+int
+main()
+{
+	short x;
+	
+	x = 0;
+	x = x + 1;
+	if (x != 1)
+		return 1;
+	return 0;
+}
--- /dev/null
+++ b/tests/0090-fptr.c
@@ -1,0 +1,21 @@
+
+struct S
+{
+	int	(*fptr)();
+};
+
+int
+foo()
+{
+	return 0;
+}
+
+int
+main()
+{
+	struct S v;
+	
+	v.fptr = foo;
+	return v.fptr();
+}
+
--- /dev/null
+++ b/tests/0091-fptr.c
@@ -1,0 +1,12 @@
+
+int (*fptr)() = 0;
+
+
+int
+main()
+{
+	if (fptr)
+		return 1;
+	return 0;
+}
+
--- /dev/null
+++ b/tests/0092-fptr.c
@@ -1,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();
+}
--- /dev/null
+++ b/tests/0093-arrayinit.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0094-arrayinit.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0095-arrayselector.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0096-inferredarraysize.c
@@ -1,0 +1,12 @@
+
+
+int a[] = {1, 2, 3, 4};
+
+int
+main()
+{
+	if (sizeof(a) != 4*sizeof(int))
+		return 1;
+	
+	return 0;
+}
--- /dev/null
+++ b/tests/0097-extern.c
@@ -1,0 +1,6 @@
+extern int x;
+
+int main()
+{
+	return 0;
+}
--- /dev/null
+++ b/tests/0098-tentative.c
@@ -1,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;
+}
+
--- /dev/null
+++ b/tests/0099-tentative.c
@@ -1,0 +1,13 @@
+
+int x, x = 3, x;
+
+int
+main()
+{
+	if (x != 3)
+		return 0;
+
+	x = 0;
+	return x;
+}
+
--- /dev/null
+++ b/tests/0100-redeclaremacro.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0101-wcharlit.c
@@ -1,0 +1,6 @@
+
+int
+main()
+{
+	return L'\0';
+}
--- /dev/null
+++ b/tests/0102-bug.c
@@ -1,0 +1,14 @@
+// This wouldn't compile
+
+typedef struct  { } Vec;
+
+static void
+vecresize(Vec *v, int cap)
+{
+	return;
+}
+
+int main()
+{
+	return 0;
+}
--- /dev/null
+++ b/tests/0103-voidparm.c
@@ -1,0 +1,12 @@
+
+int
+foo(void)
+{
+	return 0;
+}
+
+int
+main()
+{
+	return foo();
+}
--- /dev/null
+++ b/tests/0104-voidparm.c
@@ -1,0 +1,11 @@
+
+int
+main()
+{
+  int c;
+  c = 0;
+  do
+    ;
+  while (0);
+  return c;
+}
--- /dev/null
+++ b/tests/0105-shl.c
@@ -1,0 +1,12 @@
+
+int
+main()
+{
+	int x;
+	
+	x = 1;
+	if ((x << 1) != 2)
+		return 1;
+	
+	return 0;
+}
--- /dev/null
+++ b/tests/0106-ppcast.c
@@ -1,0 +1,15 @@
+
+int
+main()
+{
+	int x;
+	void *foo;
+	void **bar;
+	
+	x = 0;
+	
+	foo = (void*)&x;
+	bar = &foo;
+	
+	return **(int**)bar;
+}
--- /dev/null
+++ b/tests/0107-bnot.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0108-bug.c
@@ -1,0 +1,13 @@
+
+
+int
+main()
+{
+	int i;
+
+	for(i = 0; i < 10; i++)
+		if (!i)
+			continue;
+	
+	return 0;
+}
--- a/tests/scc-tests.lst
+++ b/tests/scc-tests.lst
@@ -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