ref: eadc7784288c38da564aa1f11602d0c195f5dabb
parent: b9158535e95666900dd3f78ebb53eb7a0dba964f
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 1 15:28:07 EDT 2015
Make fold a bit more robust These default cases make that in unknown operations the behaviour is correct, because in other case the operation is directly ignored.
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -86,6 +86,7 @@
foldint(int op, Symbol *res, TINT l, TINT r)
{
TINT i;
+ Type *tp = res->type;
bool (*validate)(TINT, TINT, Type *tp);
switch (op) {
@@ -99,7 +100,7 @@
default: validate = NULL; break;
}
- if (validate && !(*validate)(l, r, res->type))
+ if (validate && !(*validate)(l, r, tp))
return 0;
switch (op) {
@@ -123,6 +124,7 @@
case ONE: i = l != r; break;
case ONEG: i = -l; break;
case OCPL: i = ~l; break;
+ default: return 0;
}
res->u.i = i;
return 1;
@@ -155,6 +157,7 @@
case OLE: i = l <= r; goto unsign;
case OEQ: i = l == r; goto unsign;
case ONE: i = l != r; goto unsign;
+ default: return 0;
}
sign:
@@ -201,7 +204,7 @@
TUINT u;
TFLOAT f;
- aux.type = ls->type;
+ aux.type = tp;
switch (type) {
case INT:
i = (rs) ? rs->u.i : 0;