Clearing out more segfaults
This commit is contained in:
parent
0a07af340b
commit
65444b33d2
44
cc_core.c
44
cc_core.c
|
@ -1733,6 +1733,44 @@ void expression()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int iskeywordp(char* s)
|
||||||
|
{
|
||||||
|
if(match("auto", s)) return TRUE;
|
||||||
|
if(match("break", s)) return TRUE;
|
||||||
|
if(match("case", s)) return TRUE;
|
||||||
|
if(match("char", s)) return TRUE;
|
||||||
|
if(match("const", s)) return TRUE;
|
||||||
|
if(match("continue", s)) return TRUE;
|
||||||
|
if(match("default", s)) return TRUE;
|
||||||
|
if(match("do", s)) return TRUE;
|
||||||
|
if(match("double", s)) return TRUE;
|
||||||
|
if(match("else", s)) return TRUE;
|
||||||
|
if(match("enum", s)) return TRUE;
|
||||||
|
if(match("extern", s)) return TRUE;
|
||||||
|
if(match("float", s)) return TRUE;
|
||||||
|
if(match("for", s)) return TRUE;
|
||||||
|
if(match("goto", s)) return TRUE;
|
||||||
|
if(match("if", s)) return TRUE;
|
||||||
|
if(match("int", s)) return TRUE;
|
||||||
|
if(match("long", s)) return TRUE;
|
||||||
|
if(match("register", s)) return TRUE;
|
||||||
|
if(match("return", s)) return TRUE;
|
||||||
|
if(match("short", s)) return TRUE;
|
||||||
|
if(match("signed", s)) return TRUE;
|
||||||
|
if(match("sizeof", s)) return TRUE;
|
||||||
|
if(match("static", s)) return TRUE;
|
||||||
|
if(match("struct", s)) return TRUE;
|
||||||
|
if(match("switch", s)) return TRUE;
|
||||||
|
if(match("typedef", s)) return TRUE;
|
||||||
|
if(match("union", s)) return TRUE;
|
||||||
|
if(match("unsigned", s)) return TRUE;
|
||||||
|
if(match("void", s)) return TRUE;
|
||||||
|
if(match("volatile", s)) return TRUE;
|
||||||
|
if(match("while", s)) return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Process local variable */
|
/* Process local variable */
|
||||||
void collect_local()
|
void collect_local()
|
||||||
{
|
{
|
||||||
|
@ -1746,6 +1784,9 @@ void collect_local()
|
||||||
}
|
}
|
||||||
struct type* type_size = type_name();
|
struct type* type_size = type_name();
|
||||||
require(NULL != global_token, "Received EOF while collecting locals\n");
|
require(NULL != global_token, "Received EOF while collecting locals\n");
|
||||||
|
require(!in_set(global_token->s[0], "[{(<=>)}]|&!^%;:'\""), "forbidden character in local variable name\n");
|
||||||
|
require(!iskeywordp(global_token->s), "You are not allowed to use a keyword as a local variable name\n");
|
||||||
|
require(NULL != type_size, "Must have non-null type\n");
|
||||||
struct token_list* a = sym_declare(global_token->s, type_size, function->locals);
|
struct token_list* a = sym_declare(global_token->s, type_size, function->locals);
|
||||||
if(match("main", function->s) && (NULL == function->locals))
|
if(match("main", function->s) && (NULL == function->locals))
|
||||||
{
|
{
|
||||||
|
@ -2360,6 +2401,7 @@ void collect_arguments()
|
||||||
{
|
{
|
||||||
type_size = type_name();
|
type_size = type_name();
|
||||||
require(NULL != global_token, "Received EOF when attempting to collect arguments\n");
|
require(NULL != global_token, "Received EOF when attempting to collect arguments\n");
|
||||||
|
require(NULL != type_size, "Must have non-null type\n");
|
||||||
if(global_token->s[0] == ')')
|
if(global_token->s[0] == ')')
|
||||||
{
|
{
|
||||||
/* foo(int,char,void) doesn't need anything done */
|
/* foo(int,char,void) doesn't need anything done */
|
||||||
|
@ -2368,6 +2410,8 @@ void collect_arguments()
|
||||||
else if(global_token->s[0] != ',')
|
else if(global_token->s[0] != ',')
|
||||||
{
|
{
|
||||||
/* deal with foo(int a, char b) */
|
/* deal with foo(int a, char b) */
|
||||||
|
require(!in_set(global_token->s[0], "[{(<=>)}]|&!^%;:'\""), "forbidden character in argument variable name\n");
|
||||||
|
require(!iskeywordp(global_token->s), "You are not allowed to use a keyword as a argument variable name\n");
|
||||||
a = sym_declare(global_token->s, type_size, function->arguments);
|
a = sym_declare(global_token->s, type_size, function->arguments);
|
||||||
if(NULL == function->arguments)
|
if(NULL == function->arguments)
|
||||||
{
|
{
|
||||||
|
|
|
@ -432,6 +432,7 @@ struct token_list* read_all_tokens(FILE* a, struct token_list* current, char* fi
|
||||||
while(EOF != ch)
|
while(EOF != ch)
|
||||||
{
|
{
|
||||||
ch = get_token(ch);
|
ch = get_token(ch);
|
||||||
|
require(NULL != token, "Empty files don't need to be compiled\n");
|
||||||
if(match("#FILENAME", token->s)) ch = change_filename(ch);
|
if(match("#FILENAME", token->s)) ch = change_filename(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,10 +265,10 @@ c23c7615009ab8824ce7c2c60051a0e86bae85a6c1b62f3d0f34fd4d4c691aed test/results/t
|
||||||
922a7955d68afda9781a70707dac2446d51d729eb3434a8abc0dc1de3a3519bb test/results/test0106-riscv32-binary
|
922a7955d68afda9781a70707dac2446d51d729eb3434a8abc0dc1de3a3519bb test/results/test0106-riscv32-binary
|
||||||
55ad174b3664907997e44dbba37a3293af685c7147e21c61f5aab1aed4139644 test/results/test0106-riscv64-binary
|
55ad174b3664907997e44dbba37a3293af685c7147e21c61f5aab1aed4139644 test/results/test0106-riscv64-binary
|
||||||
4fdc00c91b376ac7ec04bebdd264cf0ac1b7024f33f9a4cdcc3d43788e1278a7 test/results/test0106-x86-binary
|
4fdc00c91b376ac7ec04bebdd264cf0ac1b7024f33f9a4cdcc3d43788e1278a7 test/results/test0106-x86-binary
|
||||||
f8b7f2927f30354314c5115c7372489f39002e025fed7c5e124f326e4715c092 test/results/test1000-aarch64-binary
|
c067cc492d9cca14959da864f0eb0c6e201927fecf4e166a12d11a8800f19e6d test/results/test1000-aarch64-binary
|
||||||
3945d164824b6b8e69d5f8c5c3c12d34958f559fc2c901cadbd8fb407d2cb7df test/results/test1000-amd64-binary
|
124f5c5bcedeb097c67b762e0f42f5d2754d086061f698499fc855efd6bdd3cb test/results/test1000-amd64-binary
|
||||||
503157b48f34479bc6f789d85bd09c5dcbdb52d3029f79cd12d4c9fc34e7a697 test/results/test1000-armv7l-binary
|
b493afc7310ca6aec7328d50bea655937576f200041b91fd0234dfa5e8262c8f test/results/test1000-armv7l-binary
|
||||||
f9d22cc553855b77f9bc3f067a98d4cf6b901de76c87dd6e4311cdd7e3b3047b test/results/test1000-knight-posix-binary
|
db0fe4ba5fe2988c2ed767103f759899c19e47e4e2c5269073f78523e9370ba2 test/results/test1000-knight-posix-binary
|
||||||
b820a71e13482da274eabda44e65c778168cd846401a6a36759f1f52b853af89 test/results/test1000-riscv32-binary
|
eae92ba549337bb2220a7f3d1e9b900c996182f38b06570f98ea9ab9286d0e9f test/results/test1000-riscv32-binary
|
||||||
3ae00970dc707aa04be049c34260903456058233f8fe9349e8e99a2d1552689a test/results/test1000-riscv64-binary
|
46871e4611482425532ba7c656f11a5261a2841724247b3fbe03e25ef6712cb6 test/results/test1000-riscv64-binary
|
||||||
27581b02dc8fd0621e37f9917da8f427d44cf8c333a4c815a1be7f0d698eef95 test/results/test1000-x86-binary
|
122de129729a76abc7af37423336bc24222e2f2b39b4b80d7a34cf4b25465f55 test/results/test1000-x86-binary
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
a486ac5e8ef342494ea6fccd188fddfe4115494cb0b8a4266601ef8e2a7571ce test/test1000/proof
|
f6372e7d0d95fc540bdf827d228a9c1b2f9d8ea13f7f9cba3960873d914f34b0 test/test1000/proof
|
||||||
|
|
Loading…
Reference in New Issue