From: Michael D. Lowis Date: Tue, 21 Oct 2014 22:35:11 +0000 (-0400) Subject: Fixed compiler warnings and turned on -Werror X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=cc98ff1f4e857a1ade93cc79bd22d6f4ba1a1595;p=proto%2Fsclpl.git Fixed compiler warnings and turned on -Werror --- diff --git a/Rakefile b/Rakefile index 52c3dc8..aa7d340 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ base_env = BuildEnv.new(echo: :command) do |env| env.build_dir('source','build/obj/source') env.build_dir('modules','build/obj/modules') env.set_toolset(:gcc) - env["CFLAGS"] += ['-DLEAK_DETECT_LEVEL=1', '--std=c99', '-Wall', '-Wextra'] #, '-Werror'] + env["CFLAGS"] += ['-DLEAK_DETECT_LEVEL=1', '--std=c99', '-Wall', '-Wextra', '-Werror'] env["CPPPATH"] += ['modules/libopts/source'] + Dir['modules/libcds/source/**/'] end @@ -27,7 +27,7 @@ end test_env = base_env.clone do |env| env.build_dir('source','build/obj_test/source') env.build_dir('modules','build/obj_test/modules') - env['CFLAGS'] += ['--coverage'] + env['CFLAGS'] += ['-O0', '--coverage'] env['LDFLAGS'] += ['--coverage'] end diff --git a/source/sclpl/codegen.c b/source/sclpl/codegen.c index a3ca7e8..14ac332 100644 --- a/source/sclpl/codegen.c +++ b/source/sclpl/codegen.c @@ -147,6 +147,7 @@ static void emit_expression(vec_t* fnlst, tree_t* p_tree, int depth) { case T_FLOAT: printf("__float(%f)", *((double*)tok->value)); break; case T_BOOL: printf("__bool(%s)", ((int)tok->value)?"true":"false"); break; case T_VAR: printf("%s", ((char*)tok->value)); break; + default: break; } } else if (is_formtype(p_tree, "if")) { printf("IF ("); @@ -165,15 +166,15 @@ static void emit_expression(vec_t* fnlst, tree_t* p_tree, int depth) { } } else if (is_formtype(p_tree, "fn")) { - printf("__func(&fn%d)", get_fn_id(fnlst, p_tree)); + printf("__func(&fn%d)", (int)get_fn_id(fnlst, p_tree)); } else { vec_t* vec = p_tree->ptr.vec; - size_t nargs = vec_size(vec)-1; + int nargs = vec_size(vec)-1; /* Determine the calling convention based on number of args */ if (0 == nargs) printf("__call0(%s", (char*)get_val(vec_at(vec,0))); else if (nargs < 16) - printf("__calln(%s, %d, ", (char*)get_val(vec_at(vec,0)), nargs); + printf("__calln(%s, %d, ", (char*)get_val(vec_at(vec,0)), (int)nargs); else printf("__calln(%s, n, ", (char*)get_val(vec_at(vec,0))); /* Print out the arguments */ @@ -189,7 +190,7 @@ static void emit_expression(vec_t* fnlst, tree_t* p_tree, int depth) { static void emit_fn_declarations(vec_t* fnlst) { char name[64]; for (size_t idx = 0; idx < vec_size(fnlst); idx++) { - sprintf(name,"fn%d", idx); + sprintf(name,"fn%d", (int)idx); printf("static "); emit_fn_signature(name, (tree_t*)vec_at(fnlst,idx)); puts(";"); @@ -201,7 +202,7 @@ static void emit_fn_definitions(vec_t* fnlst) { char name[64]; for (size_t idx = 0; idx < vec_size(fnlst); idx++) { tree_t* func = (tree_t*)vec_at(fnlst,idx); - sprintf(name,"fn%d", idx); + sprintf(name,"fn%d", (int)idx); printf("static "); emit_fn_signature(name, func); puts(" {"); @@ -250,6 +251,7 @@ static void emit_footer(void) { } void codegen_csource(FILE* file, vec_t* program) { + (void)file; emit_header(); emit_def_placeholders(program); vec_t* funcs = find_fn_literals(program); diff --git a/source/sclpl/main.c b/source/sclpl/main.c index 5c8182f..6ebb8f5 100644 --- a/source/sclpl/main.c +++ b/source/sclpl/main.c @@ -6,10 +6,12 @@ #include "parser.h" #include "lexer.h" #include "pprint.h" +#include "codegen.h" /* Command Line Options *****************************************************************************/ const char Usage[] = "Usage: sclpl [OPTION]... MODE [FILE]...\n"; + opts_cfg_t Options_Config[] = { {"tokens", false, "mode", "Emit the token output of lexical analysis for the given file"}, {"ast", false, "mode", "Emit the abstract syntax tree for the given file"}, @@ -42,7 +44,7 @@ void print_usage(void) { /* Print the usage and option list */ puts(Usage); - size_t padding = sz + 4 + ((opts_have_args) ? 4 : 0); + int padding = sz + 4 + ((opts_have_args) ? 4 : 0); char* buffer = (char*)malloc(padding+1); opts = &Options_Config[0]; while (NULL != opts->name) {