shithub: scc

Download patch

ref: bf7236ddf91b0242a3960fb3f66391e1a51b4a74
parent: c9538a1cb5279a7a70695c86ad31ea9f85436d59
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Sep 2 13:20:41 EDT 2015

Add basic test for integer constant folding

--- /dev/null
+++ b/cc1/tests/test019.c
@@ -1,0 +1,61 @@
+
+/*
+name: TEST019
+description: Basic test of constant folding in integer arithmetic operations
+output:
+test019.c:13: warning: division by 0
+test019.c:14: warning: division by 0
+F1
+G1	F1	main
+{
+-
+A2	I	i
+	A2	#I3	:I
+	A2	#I1	:I
+	A2	#I12	:I
+	A2	#I2	:I
+	A2	#I0	:I
+	A2	A2	#I0	%I	:I
+	A2	A2	#I0	%I	:I
+	A2	#I8	:I
+	A2	#I2	:I
+	A2	#I4	:I
+	A2	#IC	:I
+	A2	#I8	:I
+	A2	#IFFFFFFFD	:I
+	A2	#IFFFFFFF3	:I
+	A2	#I1	:I
+	A2	#I0	:I
+	A2	#I0	:I
+	A2	#I1	:I
+	A2	#I0	:I
+}
+*/
+
+#line 1
+
+int
+main(void)
+{
+	int i;
+
+	i = 1 + 2;
+	i = 2 - 1;
+	i = 3 * 6;
+	i = 10 / 5;
+	i = 10 % 5;
+	i = i % 0;
+	i = i % 0;
+	i = 1 << 3;
+	i = 8 >> 2;
+	i = 12 & 4;
+	i = 8 | 4;
+	i = 12 ^ 4;
+	i = -(3);
+	i = ~12;
+	i = 1 < 3;
+	i = 2 > 3;
+	i = 2 >= 3;
+	i = 2 <= 3;
+	i = 1 == 0;
+}