Fix Problem with global arrays #18
This commit is contained in:
parent
4af9b79c1b
commit
0577243444
30
cc_core.c
30
cc_core.c
|
@ -96,7 +96,12 @@ struct token_list* sym_lookup(char *s, struct token_list* symbol_list)
|
|||
|
||||
void line_error_token(struct token_list *token)
|
||||
{
|
||||
require(NULL != token, "EOF reached inside of line_error\n");
|
||||
if(NULL == token)
|
||||
{
|
||||
fputs("EOF reached inside of line_error\n", stderr);
|
||||
fputs("problem at end of file\n", stderr);
|
||||
return;
|
||||
}
|
||||
fputs(token->filename, stderr);
|
||||
fputs(":", stderr);
|
||||
fputs(int2str(token->linenumber, 10, TRUE), stderr);
|
||||
|
@ -110,7 +115,14 @@ void line_error()
|
|||
|
||||
void require_match(char* message, char* required)
|
||||
{
|
||||
require(NULL != global_token, "EOF reached inside of require match\n");
|
||||
if(NULL == global_token)
|
||||
{
|
||||
line_error();
|
||||
fputs("EOF reached inside of require match\n", stderr);
|
||||
fputs("problem at end of file\n", stderr);
|
||||
fputs(message, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(!match(global_token->s, required))
|
||||
{
|
||||
line_error();
|
||||
|
@ -118,7 +130,6 @@ void require_match(char* message, char* required)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
global_token = global_token->next;
|
||||
require(NULL != global_token, "EOF after require match occurred\n");
|
||||
}
|
||||
|
||||
void maybe_bootstrap_error(char* feature)
|
||||
|
@ -2066,21 +2077,26 @@ void global_static_array(struct type* type_size, struct token_list* name)
|
|||
if(match("-", global_token->s))
|
||||
{
|
||||
line_error();
|
||||
fputs("Negative values are not supported\n", stderr);
|
||||
fputs("Negative values are not supported for allocated arrays\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* length */
|
||||
size = strtoint(global_token->s) * type_size->size;
|
||||
|
||||
/* Stop bad states */
|
||||
if((size < 0) || (size > 0x100000))
|
||||
{
|
||||
line_error();
|
||||
fputs("M2-Planet is very inefficient so you probably don't want to allocate over 1MB into your binary for NULLs\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Ensure properly closed */
|
||||
global_token = global_token->next;
|
||||
require_match("missing close bracket\n", "]");
|
||||
require_match("missing ;\n", ";");
|
||||
|
||||
/* Stop bad states */
|
||||
require(size > 0, "M2-Planet is very inefficient so you probably don't want to allocate over 1MB into your binary for NULLs\n");
|
||||
require(size < 0x100000, "M2-Planet is very inefficient so you probably don't want to allocate over 1MB into your binary for NULLs\n");
|
||||
globals_list = emit("\n'", globals_list);
|
||||
while (0 != size)
|
||||
{
|
||||
|
|
|
@ -212,9 +212,9 @@ eb1f6aab09a1a4966f9f49a518d8aa03ca97aa7c46e443871d758a306671a85e test/results/t
|
|||
a2cbfd5f76d3be8049c6737e3fa02f191caf29b6885db006fa23f86e6eacc186 test/results/test0106-knight-posix-binary
|
||||
5d25eda44320f9ff2869d9ee5bc0808b4ffd13c8803fb922c3c6759cfa39be32 test/results/test0106-riscv64-binary
|
||||
473cc504d6cba9eaf648abcf15c83a317ff3f4a7f08f5e8936e3b35b2cc4fbc6 test/results/test0106-x86-binary
|
||||
72a81efd5238d0b3778e54a8992789e514bae4dc20e3d2ba3bede955ff2c3884 test/results/test1000-aarch64-binary
|
||||
73fec61b39c6987bd2aab038f3baf2419e3f65eaea756fdd9cb6787e6d5b84d5 test/results/test1000-amd64-binary
|
||||
c8a8b532fc30c17beb3b018a753b637b8e57108dc9e865ee9fba7041d23811ce test/results/test1000-armv7l-binary
|
||||
d13a1b0c3f153671b0c76a3fbc319945cad6298bf1a7d49f3b24f76764118f61 test/results/test1000-knight-posix-binary
|
||||
a4062d4cea279aa7157f700517885be19387b616a9e1c130ead394d1330190d1 test/results/test1000-riscv64-binary
|
||||
f12f2adf7bcbb07b0c124507846b821a8473dec4e4d2e83b26df6bd14bd878dd test/results/test1000-x86-binary
|
||||
a97a1d59c9548115a404d70b6341c47c5dd3bf2e9ef359f5834fd967cf3179ab test/results/test1000-aarch64-binary
|
||||
cb2d1ebc31e9c5e2701ed1da6baea3c137ea8e07a0397196458473a17e63a697 test/results/test1000-amd64-binary
|
||||
e164c932628261716f6d8bde9e07945c22c3a5db922471edc8814de0450a1c36 test/results/test1000-armv7l-binary
|
||||
0e5559a2f1453da101754c10a190ff2c327d713731faf66d42051bbf69ee74b4 test/results/test1000-knight-posix-binary
|
||||
cefaa8654e91d962058ea6c68dd33e45aa4ebe9947cacf72561e2221f1744e92 test/results/test1000-riscv64-binary
|
||||
76b7b1faf97eb18e9d83f3305dcd815f7c7ab2ee57f61bcda5773e731c8346eb test/results/test1000-x86-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
05399860cbc9a4c007c49b5a175610c7ec624206367969b195f4406f7c3cf755 test/test1000/proof
|
||||
2da2d58ea83e905ddbb14a50186a14486ac9770b8ccdf585d3bb281c64db52eb test/test1000/proof
|
||||
|
|
Loading…
Reference in New Issue