commit a993e8c13722106027d20e89369be1cc02753083
parent 5bb717efd8b6fab5fa7bc324dce6b0a8e4261f86
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 15 Aug 2015 11:03:12 +0200
Remove comparision in constant conditions
This was a very idea because it is easier to detect
a zero or an one than a comparision
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -1161,7 +1161,7 @@ condition(void)
expect('(');
np = exp2cond(expr(), 0);
if (np->constant)
- np = node(ONE, inttype, np, constnode(zero));
+ warn("conditional expression is constant");
expect(')');
return np;
diff --git 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 @@ main()
}
return 1;
}
-