]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Fixed compiler warnings and turned on -Werror
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 21 Oct 2014 22:35:11 +0000 (18:35 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 21 Oct 2014 22:35:11 +0000 (18:35 -0400)
Rakefile
source/sclpl/codegen.c
source/sclpl/main.c

index 52c3dc8184120b19974d48ffc2552a5b13bd1d44..aa7d3406ae6ebe1aee2bd40e88d2a07311ef1c98 100644 (file)
--- 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
 
index a3ca7e80d2f51df3ee91e9e5711fb99bb77ea5a4..14ac3322fad7444e7701a07f006afdc3a3ca6597 100644 (file)
@@ -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);
index 5c8182fd54c3222772111e03ef2870e55c19b606..6ebb8f5e34dfd76b8fe695c7f621c81effe8f829 100644 (file)
@@ -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) {