ref: a993e8c13722106027d20e89369be1cc02753083
parent: 5bb717efd8b6fab5fa7bc324dce6b0a8e4261f86
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Aug 15 07:03:12 EDT 2015
Remove comparision in constant conditions This was a very idea because it is easier to detect a zero or an one than a comparision
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -1161,7 +1161,7 @@
expect('(');
np = exp2cond(expr(), 0);
if (np->constant)
- np = node(ONE, inttype, np, constnode(zero));
+ warn("conditional expression is constant");
expect(')');
return np;
--- a/cc1/tests/test006.c
+++ b/cc1/tests/test006.c
@@ -2,19 +2,22 @@
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
G1 M c
F1
X2 F1 main
G2 F1 main {
-
- j L2 #I0 #I0 =I
+ j L2 #I0
yI #I1
j L3
L2
- j L4 #I0 #I0 =I
+ j L4 #I0
j L5
L4
- j L6 #I1 #I0 =I
+ j L6 #I1
j L7 G1 MI #I0 =I
yI #I1
j L8
@@ -52,4 +55,3 @@
}
return 1;
}
-