shithub: scc

Download patch

ref: a86e1949ea1d59dcdf1e89ecdf0e2b53865efc46
parent: 5c3dd68b9c8862b5eee0f9b9f08928c702e7c607
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Aug 15 17:43:36 EDT 2015

Add basic test for break and continue statements

This patch also adds a #line directive in test006.c
to aovid the problems related to the change in the
size of the output (different lines in the warnings).

--- a/cc1/tests/test006.c
+++ b/cc1/tests/test006.c
@@ -2,9 +2,9 @@
 name: TEST006
 description: Basic test for if
 output:
-test006.c:42: warning: conditional expression is constant
-test006.c:44: warning: conditional expression is constant
-test006.c:47: warning: conditional expression is constant
+test006.c:6: warning: conditional expression is constant
+test006.c:8: warning: conditional expression is constant
+test006.c:11: warning: conditional expression is constant
 G1	M	c
 F1
 G2	F1	main
@@ -35,6 +35,8 @@
 */
 
 char c;
+
+#line 1
 
 int
 main()
--- /dev/null
+++ b/cc1/tests/test010.c
@@ -1,0 +1,94 @@
+/*
+name: TEST010
+description: Test for continue and break statements
+output:
+test010.c:9: warning: conditional expression is constant
+test010.c:11: warning: conditional expression is constant
+test010.c:31: warning: conditional expression is constant
+F1
+G1	F1	main
+{
+-
+A2	I	x
+	A2	#I0	:I
+	j	L5
+	d
+L3
+	j	L4
+L5
+	j	L3	#I1
+	b
+L4
+	j	L8
+	d
+L6
+	j	L9	A2	#I5	!I
+	j	L7
+L9
+	A2	A2	#I1	+I	:I
+	j	L6
+L8
+	j	L6	#I1
+	b
+L7
+
+	j	L12
+	d
+L10
+	j	L13	A2	#IA	!I
+	j	L11
+L13
+	A2	A2	#I1	+I	:I
+	j	L10
+
+L12
+	j	L10
+	b
+L11
+	d
+L14
+	j	L16	A2	#IF	!I
+	j	L15
+L16
+	A2	A2	#I1	+I	:I
+	j	L14
+	j	L14	#I1
+	b
+L15
+	yI	A2	#IF	-I
+}
+*/
+
+#line 1
+
+int
+main()
+{
+	int x;
+	
+	x = 0;
+	while(1)
+		break;
+	while(1) {
+		if (x == 5) {
+			break;
+		}
+		x = x + 1;
+		continue;
+	}
+	for (;;) {
+		if (x == 10) {
+			break;
+		}
+		x = x + 1;
+		continue;
+	}
+	do {
+		if (x == 15) {
+			break;
+		}
+		x = x + 1;
+		continue;
+	} while(1);
+	return x - 15;
+}