commit 5d4645c1007dbbd708d7e99854594fb0db193848
parent eb9387c7d79bb73b5481decf9aa69a00707fa26b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 20 May 2016 15:29:54 +0200
[cc1] Add abort() calls in type switches
We have seen that this defensive technique is very good in a
program like a compiler, where we have dozen of different
conditions and code paths.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/cc1/types.c b/cc1/types.c
@@ -284,6 +284,8 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
case UNION:
type.prop |= TAGGREG;
break;
+ default:
+ abort();
}
t = (op ^ (uintptr_t) tp >> 3) & NR_TYPE_HASH-1;
@@ -342,5 +344,7 @@ eqtype(Type *tp1, Type *tp2)
case INT:
case FLOAT:
return tp1->letter == tp2->letter;
+ default:
+ abort();
}
}