commit 4deece51bfadf521d8509a1bb62531f9937719ab
parent 753a0f5c2d7a5f6538a9ecc9b93b89ada78459d2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 22 Apr 2014 16:22:32 +0200
Fix compare()
A comparision has always a integer type, but the operation
done in the Node may not be a integer operation. The node
of the type also help in order to know what version of
the operator must be done, so in this case we have to
put the type of the operands, and let that eval() convert
the Node type to integer where it is necessary.
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/expr.c b/expr.c
@@ -210,6 +210,13 @@ arithmetic(char op, Node *np1, Node *np2)
return bincode(op, np1->type, np1, np2);
}
+/*
+ * FIXME:
+ * Pointers to the same basic type after removing type qualifiers
+ * can be compared. It means that utype pointer must be a field
+ * of the type, not of the Node, because in other case is
+ * hard doing this check
+ */
static Node *
pcompare(char op, Node *np1, Node *np2)
{
@@ -222,7 +229,7 @@ pcompare(char op, Node *np1, Node *np2)
"comparision between different pointer types");
}
- return bincode(op, inttype, np1, np2);
+ return bincode(op, np1->type, np1, np2);
}
static Node *