fix a bunch of warnings (reported by cparser)
authorMatthias Braun <matze@braunis.de>
Wed, 15 Jun 2011 17:03:21 +0000 (19:03 +0200)
committerMatthias Braun <matze@braunis.de>
Fri, 17 Jun 2011 11:37:10 +0000 (13:37 +0200)
13 files changed:
ast.c
ast2firm.c
attribute.c
driver/firm_opt.c
driver/firm_timing.c
format_check.c
lexer.c
main.c
parser.c
preprocessor.c
type.c
types.h
wrappergen/write_jna.c

diff --git a/ast.c b/ast.c
index a2812b8..7361608 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -213,7 +213,7 @@ static void print_quoted_string(const string_t *const string, char border,
        print_char(border);
        const char *end = string->begin + string->size - skip;
        for (const char *c = string->begin; c != end; ++c) {
-               unsigned char const tc = *c;
+               const char tc = *c;
                if (tc == border) {
                        print_string("\\");
                }
@@ -233,7 +233,7 @@ static void print_quoted_string(const string_t *const string, char border,
                        }
                        /* FALLTHROUGH */
                default:
-                       if (tc < 0x80 && !isprint(tc)) {
+                       if ((unsigned)tc < 0x80 && !isprint(tc)) {
                                print_format("\\%03o", (unsigned)tc);
                        } else {
                                print_char(tc);
index a37206d..3db09b4 100644 (file)
@@ -112,12 +112,6 @@ typedef enum declaration_kind_t {
 } declaration_kind_t;
 
 static ir_mode *get_ir_mode_storage(type_t *type);
-/*
- * get arithmetic mode for a type. This is different from get_ir_mode_storage,
- * int that it returns bigger modes for floating point on some platforms
- * (x87 internally does arithemtic with 80bits)
- */
-static ir_mode *get_ir_mode_arithmetic(type_t *type);
 
 static ir_type *get_ir_type_incomplete(type_t *type);
 
@@ -786,6 +780,11 @@ static ir_mode *get_ir_mode_storage(type_t *type)
        return mode;
 }
 
+/*
+ * get arithmetic mode for a type. This is different from get_ir_mode_storage,
+ * int that it returns bigger modes for floating point on some platforms
+ * (x87 internally does arithemtic with 80bits)
+ */
 static ir_mode *get_ir_mode_arithmetic(type_t *type)
 {
        ir_mode *mode = get_ir_mode_storage(type);
@@ -2458,7 +2457,7 @@ static ir_node *handle_assume_compare(dbg_info *dbi,
                return res;
        }
 
-       expression_t *con;
+       expression_t *con = NULL;
        if (is_local_variable(op1) && is_constant_expression(op2) == EXPR_CLASS_CONSTANT) {
                var = op1->reference.entity;
                con = op2;
index 651c6ee..3e2101b 100644 (file)
@@ -227,7 +227,7 @@ static void handle_attribute_aligned(const attribute_t *attribute,
                break;
        case ENTITY_STRUCT:
        case ENTITY_UNION:
-               if (alignment > entity->compound.alignment) {
+               if (alignment > (int)entity->compound.alignment) {
                        entity->compound.alignment = alignment;
                }
                break;
index 053960d..5d78a86 100644 (file)
@@ -69,7 +69,7 @@ struct a_firm_be_opt {
 };
 
 /* optimization settings */
-struct a_firm_opt firm_opt = {
+static struct a_firm_opt firm_opt = {
        .const_folding    =  true,
        .cse              =  true,
        .confirm          =  true,
@@ -88,7 +88,7 @@ struct a_firm_opt firm_opt = {
 };
 
 /* dumping options */
-struct a_firm_dump firm_dump = {
+static struct a_firm_dump firm_dump = {
        .debug_print  = false,
        .all_types    = false,
        .no_blocks    = false,
@@ -412,7 +412,7 @@ static opt_config_t opts[] = {
 #undef IRG
 };
 static const int n_opts = sizeof(opts) / sizeof(opts[0]);
-ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
+static ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
 
 static opt_config_t *get_opt(const char *name)
 {
index 09e72c0..7d6f9b7 100644 (file)
@@ -17,8 +17,8 @@ typedef struct timer_info_t {
        ir_timer_t          *timer;
 } timer_info_t;
 
-timer_info_t *infos;
-timer_info_t *last_info;
+static timer_info_t *infos;
+static timer_info_t *last_info;
 
 void timer_register(ir_timer_t *timer, const char *description)
 {
index 4dbd932..38423d9 100644 (file)
@@ -88,7 +88,7 @@ static const char* get_length_modifier_name(const format_length_modifier_t mod)
                [FMT_MOD_I32]  = "I32",
                [FMT_MOD_I64]  = "I64"
        };
-       assert(mod < lengthof(names));
+       assert((size_t)mod < lengthof(names));
        return names[mod];
 }
 
@@ -943,31 +943,27 @@ void check_format(const call_expression_t *const call)
        const entity_t        *const entity = func_expr->reference.entity;
        const call_argument_t *      arg    = call->arguments;
 
-       if (false) {
-               /* the declaration has a GNU format attribute, check it */
-       } else {
-               /*
-                * For some functions we always check the format, even if it was not
-                * specified. This allows to check format even in MS mode or without
-                * header included.
-                */
-               const char *const name = entity->base.symbol->string;
-               for (size_t i = 0; i < lengthof(builtin_table); ++i) {
-                       if (strcmp(name, builtin_table[i].name) == 0) {
-                               switch (builtin_table[i].fmt_kind) {
-                               case FORMAT_PRINTF:
-                                       check_printf_format(arg, &builtin_table[i]);
-                                       break;
-                               case FORMAT_SCANF:
-                                       check_scanf_format(arg, &builtin_table[i]);
-                                       break;
-                               case FORMAT_STRFTIME:
-                               case FORMAT_STRFMON:
-                                       /* TODO: implement other cases */
-                                       break;
-                               }
+       /*
+        * For some functions we always check the format, even if it was not
+        * specified. This allows to check format even in MS mode or without
+        * header included.
+        */
+       const char *const name = entity->base.symbol->string;
+       for (size_t i = 0; i < lengthof(builtin_table); ++i) {
+               if (strcmp(name, builtin_table[i].name) == 0) {
+                       switch (builtin_table[i].fmt_kind) {
+                       case FORMAT_PRINTF:
+                               check_printf_format(arg, &builtin_table[i]);
+                               break;
+                       case FORMAT_SCANF:
+                               check_scanf_format(arg, &builtin_table[i]);
+                               break;
+                       case FORMAT_STRFTIME:
+                       case FORMAT_STRFMON:
+                               /* TODO: implement other cases */
                                break;
                        }
+                       break;
                }
        }
 }
diff --git a/lexer.c b/lexer.c
index 9697a51..c7cc960 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -56,7 +56,7 @@
 static utf32             c;
 static source_position_t lexer_pos;
 token_t                  lexer_token;
-symbol_t                *symbol_L;
+static symbol_t         *symbol_L;
 static FILE             *input;
 static utf32             buf[BUF_SIZE + MAX_PUTBACK];
 static const utf32      *bufend;
@@ -1423,14 +1423,13 @@ static void parse_preprocessor_directive(void)
 #define ELSE_CODE(code)                                    \
                                default:                                   \
                                        code                                   \
+                                       return;                                \
                                }                                          \
                        } /* end of while (true) */                    \
-                       break;
 
 #define ELSE(set_type)                                     \
                ELSE_CODE(                                         \
                        lexer_token.type = set_type;                   \
-                       return;                                        \
                )
 
 void lexer_next_preprocessing_token(void)
@@ -1487,7 +1486,6 @@ void lexer_next_preprocessing_token(void)
                                                put_back(c);
                                                c = '.';
                                                lexer_token.type = '.';
-                                               return;
                                        )
                        ELSE('.')
                case '&':
@@ -1541,7 +1539,6 @@ void lexer_next_preprocessing_token(void)
                                                                put_back(c);
                                                                c = '%';
                                                                lexer_token.type = '#';
-                                                               return;
                                                        )
                                        ELSE('#')
                        ELSE('%')
diff --git a/main.c b/main.c
index b0a477d..9d3e8e7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -103,7 +103,6 @@ unsigned int       machine_size              = 32;
 bool               byte_order_big_endian     = false;
 bool               char_is_signed            = true;
 bool               strict_mode               = false;
-bool               use_builtins              = false;
 atomic_type_kind_t wchar_atomic_kind         = ATOMIC_TYPE_INT;
 unsigned           long_double_size          = 0;
 bool               enable_main_collect2_hack = false;
@@ -112,6 +111,7 @@ bool               freestanding              = false;
 static machine_triple_t *target_machine;
 static const char       *target_triple;
 static int               verbose;
+static bool              use_builtins;
 static struct obstack    cppflags_obst;
 static struct obstack    ldflags_obst;
 static struct obstack    asflags_obst;
@@ -890,21 +890,23 @@ int main(int argc, char **argv)
        obstack_init(&file_obst);
 
 #define GET_ARG_AFTER(def, args)                                             \
+       do {                                                                     \
        def = &arg[sizeof(args)-1];                                              \
-       if (def[0] == '\0') {                                                     \
+       if (def[0] == '\0') {                                                    \
                ++i;                                                                 \
-               if (i >= argc) {                                                      \
+               if (i >= argc) {                                                     \
                        fprintf(stderr, "error: expected argument after '" args "'\n");  \
                        argument_errors = true;                                          \
                        break;                                                           \
                }                                                                    \
                def = argv[i];                                                       \
-               if (def[0] == '-' && def[1] != '\0') {                                \
+               if (def[0] == '-' && def[1] != '\0') {                               \
                        fprintf(stderr, "error: expected argument after '" args "'\n");  \
                        argument_errors = true;                                          \
                        continue;                                                        \
                }                                                                    \
-       }
+       }                                                                        \
+       } while (0)
 
 #define SINGLE_OPTION(ch) (option[0] == (ch) && option[1] == '\0')
 
index 8d08d6b..baf300a 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -289,7 +289,7 @@ static size_t get_statement_struct_size(statement_kind_t kind)
                [STATEMENT_MS_TRY]      = sizeof(ms_try_statement_t),
                [STATEMENT_LEAVE]       = sizeof(leave_statement_t)
        };
-       assert(kind < lengthof(sizes));
+       assert((size_t)kind < lengthof(sizes));
        assert(sizes[kind] != 0);
        return sizes[kind];
 }
@@ -341,7 +341,7 @@ static size_t get_expression_struct_size(expression_kind_t kind)
        if (kind >= EXPR_BINARY_FIRST && kind <= EXPR_BINARY_LAST) {
                return sizes[EXPR_BINARY_FIRST];
        }
-       assert(kind < lengthof(sizes));
+       assert((size_t)kind < lengthof(sizes));
        assert(sizes[kind] != 0);
        return sizes[kind];
 }
@@ -427,7 +427,7 @@ static size_t get_initializer_size(initializer_kind_t kind)
                [INITIALIZER_LIST]        = sizeof(initializer_list_t),
                [INITIALIZER_DESIGNATOR]  = sizeof(initializer_designator_t)
        };
-       assert(kind < lengthof(sizes));
+       assert((size_t)kind < lengthof(sizes));
        assert(sizes[kind] != 0);
        return sizes[kind];
 }
@@ -703,7 +703,7 @@ static entity_t *get_entity(const symbol_t *const symbol,
        assert(namespc != NAMESPACE_INVALID);
        entity_t *entity = symbol->entity;
        for (; entity != NULL; entity = entity->base.symbol_next) {
-               if (entity->base.namespc == namespc)
+               if ((namespace_tag_t)entity->base.namespc == namespc)
                        return entity;
        }
 
@@ -716,7 +716,7 @@ static entity_t *get_tag(symbol_t const *const symbol,
                          entity_kind_tag_t const kind)
 {
        entity_t *entity = get_entity(symbol, NAMESPACE_TAG);
-       if (entity != NULL && entity->kind != kind) {
+       if (entity != NULL && (entity_kind_tag_t)entity->kind != kind) {
                errorf(HERE,
                                "'%Y' defined as wrong kind of tag (previous definition %P)",
                                symbol, &entity->base.source_position);
@@ -2949,8 +2949,10 @@ wrong_thread_storage_class:
                        break;
 
 #define CHECK_DOUBLE_TYPE()        \
+                       do { \
                        if ( type != NULL)     \
-                               errorf(HERE, "multiple data types in declaration specifiers");
+                               errorf(HERE, "multiple data types in declaration specifiers"); \
+                       } while(0)
 
                case T_struct:
                        CHECK_DOUBLE_TYPE();
@@ -5946,7 +5948,7 @@ struct expression_parser_function_t {
        parse_expression_infix_function  infix_parser;
 };
 
-expression_parser_function_t expression_parsers[T_LAST_TOKEN];
+static expression_parser_function_t expression_parsers[T_LAST_TOKEN];
 
 /**
  * Prints an error message if an expression was expected but not read
@@ -6310,7 +6312,8 @@ static entity_t *lookup_entity(const scope_t *scope, symbol_t *symbol,
           construct a hashmap here... */
        entity_t *entity = scope->entities;
        for ( ; entity != NULL; entity = entity->base.next) {
-               if (entity->base.symbol == symbol && entity->base.namespc == namespc)
+               if (entity->base.symbol == symbol
+                   && (namespace_tag_t)entity->base.namespc == namespc)
                        break;
        }
 
@@ -10702,23 +10705,17 @@ static void parse_externals(void)
 
        while (token.type != T_EOF && token.type != '}') {
 #ifndef NDEBUG
-               bool anchor_leak = false;
                for (int i = 0; i < T_LAST_TOKEN; ++i) {
                        unsigned char count = token_anchor_set[i] - token_anchor_copy[i];
                        if (count != 0) {
                                /* the anchor set and its copy differs */
                                internal_errorf(HERE, "Leaked anchor token %k %d times", i, count);
-                               anchor_leak = true;
                        }
                }
                if (in_gcc_extension) {
                        /* an gcc extension scope was not closed */
                        internal_errorf(HERE, "Leaked __extension__");
-                       anchor_leak = true;
                }
-
-               if (anchor_leak)
-                       abort();
 #endif
 
                parse_external();
index 5089a68..95743dc 100644 (file)
@@ -61,7 +61,7 @@ struct pp_input_t {
        pp_input_t        *parent;
 };
 
-pp_input_t input;
+static pp_input_t input;
 #define CC input.c
 
 static pp_input_t     *input_stack;
@@ -70,7 +70,7 @@ static struct obstack  input_obstack;
 
 static pp_conditional_t *conditional_stack;
 
-token_t                   pp_token;
+static token_t            pp_token;
 static bool               resolve_escape_sequences = false;
 static bool               do_print_spaces          = true;
 static bool               do_expansions;
@@ -951,15 +951,14 @@ end_number:
 
 #define ELSE_CODE(code)                                    \
                                default:                                   \
-                                       code;                                  \
+                                       code                                   \
+                                       return;                                \
                                }                                          \
                        } /* end of while(1) */                        \
-                       break;
 
 #define ELSE(set_type)                                     \
                ELSE_CODE(                                         \
                        pp_token.type = set_type;                      \
-                       return;                                        \
                )
 
 static void next_preprocessing_token(void)
@@ -1027,7 +1026,6 @@ restart:
                                        put_back(CC);
                                        CC = '.';
                                        pp_token.type = '.';
-                                       return;
                                )
                ELSE('.')
        case '&':
@@ -1079,7 +1077,6 @@ restart:
                                                        put_back(CC);
                                                        CC = '%';
                                                        pp_token.type = '#';
-                                                       return;
                                                )
                                ELSE('#')
                ELSE('%')
@@ -1177,7 +1174,7 @@ static void print_quoted_string(const char *const string)
                case '\?':  fputs("\\?", out); break;
                default:
                        if(!isprint(*c)) {
-                               fprintf(out, "\\%03o", *c);
+                               fprintf(out, "\\%03o", (unsigned)*c);
                                break;
                        }
                        fputc(*c, out);
diff --git a/type.c b/type.c
index 51bad27..b8bab1d 100644 (file)
--- a/type.c
+++ b/type.c
@@ -848,7 +848,7 @@ type_t *get_qualified_type(type_t *orig_type, type_qualifiers_t const qual)
                copy                     = duplicate_type(type);
                copy->array.element_type = qual_element_type;
        } else if (is_type_valid(type)) {
-               if ((type->base.qualifiers & qual) == qual)
+               if ((type->base.qualifiers & qual) == (int)qual)
                        return orig_type;
 
                copy                   = duplicate_type(type);
diff --git a/types.h b/types.h
index f6ff56b..cb03f88 100644 (file)
--- a/types.h
+++ b/types.h
@@ -53,6 +53,7 @@ extern type_t *type_unsigned_long_ptr;
 extern type_t *type_short_ptr;
 extern type_t *type_signed_char_ptr;
 extern type_t *type_void_ptr;
+extern type_t *type_const_void;
 extern type_t *type_const_void_ptr;
 extern type_t *type_void_ptr_restrict;
 extern type_t *type_const_void_ptr_restrict;
index 6387217..1f180d2 100644 (file)
@@ -44,8 +44,6 @@ static pset_new_t     avoid_symbols;
 static output_limit  *output_limits;
 static const char    *libname;
 
-static void write_type(type_t *type);
-
 static bool is_system_header(const char *fname)
 {
        if (strncmp(fname, "/usr/include", 12) == 0)