[hackers] [scc] [cc1] Add abort() calls in type switches || Roberto E. Vargas Caballero
commit 5d4645c1007dbbd708d7e99854594fb0db193848
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri May 20 15:29:54 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri May 20 15:32:51 2016 +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.
diff --git a/cc1/types.c b/cc1/types.c
index a9d68e1..c21cc6b 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -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;
_AT_@ -342,5 +344,7 @@ eqtype(Type *tp1, Type *tp2)
case INT:
case FLOAT:
return tp1->letter == tp2->letter;
+ default:
+ abort();
}
}
Received on Fri May 20 2016 - 15:34:07 CEST
This archive was generated by hypermail 2.3.0
: Fri May 20 2016 - 15:36:21 CEST