Catch some basic segfaults

This commit is contained in:
Jeremiah Orians 2021-01-05 23:00:58 -05:00
parent 0ab7cb78eb
commit bdd4e65580
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
3 changed files with 15 additions and 8 deletions

View File

@ -123,6 +123,7 @@ int macro_primary_expr()
int macro_additive_expr()
{
int lhs = macro_primary_expr();
int hold;
if(match("+", macro_token->s))
{
@ -142,12 +143,16 @@ int macro_additive_expr()
else if(match("/", macro_token->s))
{
eat_current_token();
return lhs / macro_additive_expr();
hold = macro_additive_expr();
require(0 != hold, "divide by zero not valid even in C macros\n");
return lhs / hold;
}
else if(match("%", macro_token->s))
{
eat_current_token();
return lhs % macro_additive_expr();
hold = macro_additive_expr();
require(0 != hold, "modulus by zero not valid even in C macros\n");
return lhs % hold;
}
else if(match(">>", macro_token->s))
{
@ -279,6 +284,7 @@ void macro_directive()
{
eat_current_token();
result = macro_expression();
require(NULL != conditional_inclusion_top, "#elif without leading #if\n");
conditional_inclusion_top->include = result && !conditional_inclusion_top->previous_condition_matched;
conditional_inclusion_top->previous_condition_matched =
conditional_inclusion_top->previous_condition_matched || conditional_inclusion_top->include;
@ -286,6 +292,7 @@ void macro_directive()
else if(match("#else", macro_token->s))
{
eat_current_token();
require(NULL != conditional_inclusion_top, "#else without leading #if\n");
conditional_inclusion_top->include = !conditional_inclusion_top->previous_condition_matched;
}
else if(match("#endif", macro_token->s))

View File

@ -169,8 +169,8 @@ a2a83f42119e646b389b98647cf6cf2aa9597185997c9453db746178c8c4c0bf test/results/t
698853b79efb30865a663c4863c050639eb21c7400008f7840830503928973d4 test/results/test0106-knight-native-binary
45c2ba61dc209d7ffa39de9ff0f0a7f8f3ea4d7e38598c72f982fcaf9a05c84a test/results/test0106-knight-posix-binary
944580ff4aae38aafac139faf6eed5bfe4ff68b01a7a3adfa346de8803101182 test/results/test0106-x86-binary
0f0f720afa507a5af54ede8dc6058d8bb43d96b66b67d799374a4e9edc3e0a95 test/results/test1000-aarch64-binary
ac9e489a722bd962a47b8c170af4c3cd48c3fc5e1242865fb5a3f499f0651a45 test/results/test1000-amd64-binary
91946f5ad9efb22fb7ff106bfe74908b844f10716bf3c5fcfcb6f136146486d6 test/results/test1000-armv7l-binary
9f2764138869574ab2ccb688cb2b296fc6878d609a2079bf779440a18af966b9 test/results/test1000-knight-posix-binary
685f353b97f09bd723d035960c882e8ba793c88641716a8a4f2132bdad2f6f05 test/results/test1000-x86-binary
2ea5fa821d8271981c5dbe0886438bf92a4f64c21520b31457c15b64134ce805 test/results/test1000-aarch64-binary
522919033cfb5d810b032a1aa3d9aee62eb9bc7029bc05ac8b36a860be1f9781 test/results/test1000-amd64-binary
7a6f502c54d36df4dc208f41a2cd15546f48ca7b65bb7a1fad6b0df60267f035 test/results/test1000-armv7l-binary
943ff65e9fb5e344391d1591b208f8f690f68d8f3439a9ac772b3ae9ff53f707 test/results/test1000-knight-posix-binary
df92a06472639d93715663676cc94e24267239ace2a79265cdd9a89b9ed96584 test/results/test1000-x86-binary

View File

@ -1 +1 @@
730281bc277d68d0afc81644fea430660e4dd35762ed482bdbb0c9c733cb4baa test/test1000/proof
4f2512fe3a0b6192840fb7e8c03d75b67ed2b95d1eb45f046fccfacdc30e44c6 test/test1000/proof