Catching some segfaults
This commit is contained in:
parent
e25c1995aa
commit
c220d14928
24
cc_core.c
24
cc_core.c
|
@ -426,6 +426,9 @@ void primary_expr_string()
|
|||
strings_list = emit(":STRING_", strings_list);
|
||||
strings_list = uniqueID(function->s, strings_list, number_string);
|
||||
|
||||
/* catch case of just "foo" from segfaulting */
|
||||
require(NULL != global_token->next, "a string by itself is not valid C\n");
|
||||
|
||||
/* Parse the string */
|
||||
if('"' != global_token->next->s[0])
|
||||
{
|
||||
|
@ -567,14 +570,10 @@ void primary_expr_variable()
|
|||
void primary_expr();
|
||||
struct type* promote_type(struct type* a, struct type* b)
|
||||
{
|
||||
if(NULL == b)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
if(NULL == a)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
require(NULL != b, "impossible case 1 in promote_type\n");
|
||||
require(NULL != a, "impossible case 2 in promote_type\n");
|
||||
|
||||
if(a == b) return a;
|
||||
|
||||
struct type* i;
|
||||
for(i = global_types; NULL != i; i = i->next)
|
||||
|
@ -583,7 +582,10 @@ struct type* promote_type(struct type* a, struct type* b)
|
|||
if(b->name == i->name) break;
|
||||
if(a->name == i->indirect->name) break;
|
||||
if(b->name == i->indirect->name) break;
|
||||
if(a->name == i->indirect->indirect->name) break;
|
||||
if(b->name == i->indirect->indirect->name) break;
|
||||
}
|
||||
require(NULL != i, "impossible case 3 in promote_type\n");
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -1120,7 +1122,7 @@ void expression()
|
|||
|
||||
common_recursion(expression);
|
||||
emit_out(store);
|
||||
current_target = NULL;
|
||||
current_target = integer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1618,7 +1620,9 @@ void recursive_statement()
|
|||
struct type* lookup_type(char* s, struct type* start);
|
||||
void statement()
|
||||
{
|
||||
current_target = NULL;
|
||||
/* Always an integer until told otherwise */
|
||||
current_target = integer;
|
||||
|
||||
if(global_token->s[0] == '{')
|
||||
{
|
||||
recursive_statement();
|
||||
|
|
|
@ -37,3 +37,4 @@ int Architecture;
|
|||
int register_size;
|
||||
|
||||
int MAX_STRING;
|
||||
struct type* integer;
|
||||
|
|
|
@ -36,4 +36,8 @@ extern int string_index;
|
|||
extern int Architecture;
|
||||
extern int register_size;
|
||||
|
||||
/* Allow us to have a single settable max string */
|
||||
extern int MAX_STRING;
|
||||
|
||||
/* make default type integer */
|
||||
extern struct type* integer;
|
||||
|
|
|
@ -91,8 +91,8 @@ void initialize_types()
|
|||
prim_types = add_primitive(hold);
|
||||
|
||||
/* Define int */
|
||||
hold = new_primitive("int", "int*", "int**", register_size, TRUE);
|
||||
prim_types = add_primitive(hold);
|
||||
integer = new_primitive("int", "int*", "int**", register_size, TRUE);
|
||||
prim_types = add_primitive(integer);
|
||||
|
||||
/* Define char */
|
||||
hold = new_primitive("char", "char*", "char**", 1, TRUE);
|
||||
|
|
|
@ -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
|
||||
d88bdc8875c2266f69915a12f1dfbabc0ebf46d049cfee274e2152d0061e3649 test/results/test1000-aarch64-binary
|
||||
5182beb657413c11e8499612c8da47bf000fae579757716590819ac90f9b2e97 test/results/test1000-amd64-binary
|
||||
fa29913b7e5b56ab2f55bb40e855943a85094d51fb3f732d34333caa35fcc75d test/results/test1000-armv7l-binary
|
||||
790e3fc1fc0cef681e6d62e2379814d4c05934f7168de02f9014479e90cf967d test/results/test1000-knight-posix-binary
|
||||
d86407a4518350fadd7720f127df2d74973ab2c3a900eba68f65b6e5eb2a09c2 test/results/test1000-x86-binary
|
||||
7a0ffcce05c58dc515eeeeab4fba3cb64a7026f0371a9741396f54ac7a1751b5 test/results/test1000-aarch64-binary
|
||||
5db4502a4f74764274335402b6911a8ddd5ddc0947e7e38150d7388aeda6df31 test/results/test1000-amd64-binary
|
||||
5a5c427b932fc46d06a600672cff96113c23dc2a71d746606eceadb1aef1e2a9 test/results/test1000-armv7l-binary
|
||||
b2b9eacf785e498e86c358cfd87834016fc0b8c5ee6efa625bd5a2c9ffb4e1a1 test/results/test1000-knight-posix-binary
|
||||
0cc7d8bd6b40bcb6f3b694ab3674377b76f1b2692ee7946a39a7d4e33feebc69 test/results/test1000-x86-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
23a1ed9f3f0f21fbc6d860615ad997df9490917c31613f4543bbaeeee1e7cf8b test/test1000/proof
|
||||
fce731f1c0914873c1d882c45fa7c606673e923504b40812231c282a02cfddd9 test/test1000/proof
|
||||
|
|
Loading…
Reference in New Issue