commit a993e8c13722106027d20e89369be1cc02753083
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Sat Aug 15 11:03:12 2015 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Sat Aug 15 11:03:12 2015 +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

diff --git a/cc1/expr.c b/cc1/expr.c
index 310c3d6..ebde5b1 100644
--- 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
index 4f67fbb..529f135 100644
--- 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;
 }
-

Reply via email to