diff options
-rw-r--r-- | arr.c | 2 | ||||
-rw-r--r-- | blockarr.c | 2 | ||||
-rwxr-xr-x | build.sh | 14 | ||||
-rw-r--r-- | cgen.c | 2 | ||||
-rw-r--r-- | parse.c | 4 | ||||
-rw-r--r-- | toc.c | 2 |
6 files changed, 21 insertions, 5 deletions
@@ -140,6 +140,7 @@ You shouldn't rely on this, though, e.g. by doing #define arr_foreach(arr, type, var) for (type *var = arr_len(arr) ? arr : NULL, *var##_foreach_end = arr_last(arr); var; var == var##_foreach_end ? var = NULL : var++) #define arr_remove_last(arr) arr_remove_last_((void **)(arr), sizeof **(arr)) +#ifdef TOC_DEBUG static void arr_test(void) { int *foos = NULL; for (int i = 0; i < 1000; i++) { @@ -155,3 +156,4 @@ static void arr_test(void) { } arr_clear(&foos); } +#endif @@ -47,6 +47,7 @@ static void block_arr_free(BlockArr *arr) { arr_clear(&arr->blocks); } +#ifdef TOC_DEBUG static void block_arr_test(void) { BlockArr a; int *ps[100]; @@ -61,3 +62,4 @@ static void block_arr_test(void) { } block_arr_free(&a); } +#endif @@ -1,6 +1,10 @@ #!/bin/sh if [ "$CC" = "" ]; then - CC=gcc + if [ "$1" = "release" ]; then + CC=clang + else + CC=gcc + fi fi @@ -21,6 +25,12 @@ fi DEBUG_FLAGS="-O0 -g3 $WARNINGS -std=c11 -DTOC_DEBUG" RELEASE_FLAGS="-O3 -s -DNDEBUG $WARNINGS -std=c11" -COMMAND="$CC $DEBUG_FLAGS $ADDITIONAL_FLAGS -o toc main.c" +if [ "$1" = "release" ]; then + FLAGS="$RELEASE_FLAGS $ADDITIONAL_FLAGS" +else + FLAGS="$DEBUG_FLAGS $ADDITIONAL_FLAGS" +fi + +COMMAND="$CC $FLAGS -o toc main.c" echo $COMMAND $COMMAND || exit 1 @@ -564,7 +564,7 @@ static bool cgen_new_slice(CGenerator *g, Type *t, IdentID id, Location where) { } static bool cgen_expr_pre(CGenerator *g, Expression *e) { - IdentID id; + IdentID id = 0; char ret_name[64]; switch (e->kind) { case EXPR_IF: @@ -838,7 +838,7 @@ static bool parse_expr(Parser *p, Expression *e, Token *end) { int lowest_precedence = NOT_AN_OP; /* e.g. (5+3) */ bool entirely_within_parentheses = token_is_kw(t->token, KW_LPAREN); - Token *lowest_precedence_op; + Token *lowest_precedence_op = NULL; for (Token *token = t->token; token < end; token++) { if (token->kind == TOKEN_KW) { switch (token->kw) { @@ -1346,7 +1346,7 @@ static bool parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, uint16_ } d->type = type; } - const char *end_str; + const char *end_str = NULL; switch (ends_with) { case DECL_END_SEMICOLON: end_str = "';'"; break; case DECL_END_RPAREN_COMMA: end_str = "')' or ','"; break; @@ -27,4 +27,6 @@ #include "cgen.c" #include "decls_cgen.c" +#ifdef TOC_DEBUG #include "tests.c" +#endif |