fix cparser warnings
authorMatthias Braun <matze@braunis.de>
Fri, 17 Jun 2011 19:15:53 +0000 (21:15 +0200)
committerMatthias Braun <matze@braunis.de>
Fri, 17 Jun 2011 19:15:53 +0000 (21:15 +0200)
ast2firm.c
main.c
parser.c
type.c

index 3db09b4..7a33f35 100644 (file)
@@ -576,10 +576,10 @@ static ir_type *create_compound_type(compound_type_t *type,
                return compound->irtype;
        }
 
-       symbol_t *symbol = compound->base.symbol;
+       symbol_t *type_symbol = compound->base.symbol;
        ident    *id;
-       if (symbol != NULL) {
-               id = new_id_from_str(symbol->string);
+       if (type_symbol != NULL) {
+               id = new_id_from_str(type_symbol->string);
        } else {
                if (is_union) {
                        id = id_unique("__anonymous_union.%u");
@@ -1751,10 +1751,10 @@ static ir_node *process_builtin_call(const call_expression_t *call)
        assert(call->function->kind == EXPR_REFERENCE);
        reference_expression_t *builtin = &call->function->reference;
 
-       type_t *type = skip_typeref(builtin->base.type);
-       assert(is_type_pointer(type));
+       type_t *expr_type = skip_typeref(builtin->base.type);
+       assert(is_type_pointer(expr_type));
 
-       type_t *function_type = skip_typeref(type->pointer.points_to);
+       type_t *function_type = skip_typeref(expr_type->pointer.points_to);
 
        switch (builtin->entity->function.btk) {
        case bk_gnu_builtin_alloca: {
@@ -2038,8 +2038,8 @@ static ir_node *call_expression_to_firm(const call_expression_t *const call)
                expression_t *expression = argument->expression;
                ir_node      *arg_node   = expression_to_firm(expression);
 
-               type_t  *type = skip_typeref(expression->base.type);
-               if (!is_type_compound(type)) {
+               type_t *arg_type = skip_typeref(expression->base.type);
+               if (!is_type_compound(arg_type)) {
                        ir_mode *mode = get_ir_mode_storage(expression->base.type);
                        arg_node      = create_conv(dbgi, arg_node, mode);
                        arg_node      = do_strict_conv(dbgi, arg_node);
@@ -4451,8 +4451,8 @@ static void create_variable_initializer(entity_t *entity)
 
                ir_node *value = expression_to_firm(initializer_value->value);
 
-               type_t  *type = initializer_value->value->base.type;
-               ir_mode *mode = get_ir_mode_storage(type);
+               type_t  *init_type = initializer_value->value->base.type;
+               ir_mode *mode      = get_ir_mode_storage(init_type);
                value = create_conv(dbgi, value, mode);
                value = do_strict_conv(dbgi, value);
 
@@ -4602,7 +4602,6 @@ static void return_statement_to_firm(return_statement_t *statement)
        type_t   *type        = current_function_entity->declaration.type;
        ir_type  *func_irtype = get_ir_type(type);
 
-
        ir_node *in[1];
        int      in_len;
        if (get_method_n_ress(func_irtype) > 0) {
@@ -4611,10 +4610,10 @@ static void return_statement_to_firm(return_statement_t *statement)
                if (statement->value != NULL) {
                        ir_node *node = expression_to_firm(statement->value);
                        if (!is_compound_type(res_type)) {
-                               type_t  *type = statement->value->base.type;
-                               ir_mode *mode = get_ir_mode_storage(type);
-                               node          = create_conv(dbgi, node, mode);
-                               node          = do_strict_conv(dbgi, node);
+                               type_t  *ret_value_type = statement->value->base.type;
+                               ir_mode *mode           = get_ir_mode_storage(ret_value_type);
+                               node                    = create_conv(dbgi, node, mode);
+                               node                    = do_strict_conv(dbgi, node);
                        }
                        in[0] = node;
                } else {
@@ -5655,13 +5654,13 @@ static void initialize_function_parameters(entity_t *entity)
                }
 
                if (needs_entity) {
-                       ir_entity *entity = get_method_value_param_ent(function_irtype, n);
-                       ident     *id     = new_id_from_str(parameter->base.symbol->string);
-                       set_entity_ident(entity, id);
+                       ir_entity *param = get_method_value_param_ent(function_irtype, n);
+                       ident     *id    = new_id_from_str(parameter->base.symbol->string);
+                       set_entity_ident(param, id);
 
                        parameter->declaration.kind
                                = DECLARATION_KIND_PARAMETER_ENTITY;
-                       parameter->parameter.v.entity = entity;
+                       parameter->parameter.v.entity = param;
                        continue;
                }
 
@@ -5887,8 +5886,8 @@ static void create_function(entity_t *entity)
        int      align_all  = 4;
        int      offset     = 0;
        for (int i = 0; i < n; ++i) {
-               ir_entity *entity      = get_compound_member(frame_type, i);
-               ir_type   *entity_type = get_entity_type(entity);
+               ir_entity *member      = get_compound_member(frame_type, i);
+               ir_type   *entity_type = get_entity_type(member);
 
                int align = get_type_alignment_bytes(entity_type);
                if (align > align_all)
@@ -5901,7 +5900,7 @@ static void create_function(entity_t *entity)
                        }
                }
 
-               set_entity_offset(entity, offset);
+               set_entity_offset(member, offset);
                offset += get_type_size_bytes(entity_type);
        }
        set_type_size_bytes(frame_type, offset);
diff --git a/main.c b/main.c
index 9d3e8e7..6a0852b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1045,12 +1045,12 @@ int main(int argc, char **argv)
                                           strstart(orig_opt, "align-functions=")) {
                                        fprintf(stderr, "ignoring gcc option '-f%s'\n", orig_opt);
                                } else if (strstart(orig_opt, "visibility=")) {
-                                       const char *arg = strchr(orig_opt, '=')+1;
+                                       const char *val = strchr(orig_opt, '=')+1;
                                        elf_visibility_tag_t visibility
-                                               = get_elf_visibility_from_string(arg);
+                                               = get_elf_visibility_from_string(val);
                                        if (visibility == ELF_VISIBILITY_ERROR) {
                                                fprintf(stderr, "invalid visibility '%s' specified\n",
-                                                       arg);
+                                                       val);
                                                argument_errors = true;
                                        } else {
                                                set_default_visibility(visibility);
@@ -1188,14 +1188,12 @@ int main(int argc, char **argv)
                                        GET_ARG_AFTER(opt, "-march=");
                                        snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
                                        int res = be_parse_arg(arch_opt);
+                                       snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
+                                       res &= be_parse_arg(arch_opt);
+
                                        if (res == 0) {
                                                fprintf(stderr, "Unknown architecture '%s'\n", arch_opt);
                                                argument_errors = true;
-                                       } else {
-                                               snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
-                                               int res = be_parse_arg(arch_opt);
-                                               if (res == 0)
-                                                       argument_errors = true;
                                        }
                                } else if (strstart(opt, "tune=")) {
                                        GET_ARG_AFTER(opt, "-mtune=");
@@ -1572,13 +1570,13 @@ preprocess:
                                preprocessed_in = preprocess(filename, filetype);
                                if (mode == PreprocessOnly) {
                                        copy_file(out, preprocessed_in);
-                                       int result = pclose(preprocessed_in);
+                                       int pp_result = pclose(preprocessed_in);
                                        fclose(out);
                                        /* remove output file in case of error */
-                                       if (out != stdout && result != EXIT_SUCCESS) {
+                                       if (out != stdout && pp_result != EXIT_SUCCESS) {
                                                unlink(outname);
                                        }
-                                       return result;
+                                       return pp_result;
                                }
 
                                in = preprocessed_in;
index baf300a..c14fc47 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4728,11 +4728,11 @@ decl_list_end:
                                parameter_type = not_promoted;
                        }
                }
-               function_parameter_t *const parameter
+               function_parameter_t *const function_parameter
                        = allocate_parameter(parameter_type);
 
-               *anchor = parameter;
-               anchor  = &parameter->next;
+               *anchor = function_parameter;
+               anchor  = &function_parameter->next;
        }
 
        new_type->function.parameters = parameters;
@@ -5023,15 +5023,15 @@ static void check_reachable(statement_t *const stmt)
                case STATEMENT_DECLARATION: {
                        declaration_statement_t const *const decl = &stmt->declaration;
                        entity_t                const *      ent  = decl->declarations_begin;
-                       entity_t                const *const last = decl->declarations_end;
+                       entity_t                const *const last_decl = decl->declarations_end;
                        if (ent != NULL) {
                                for (;; ent = ent->base.next) {
                                        if (ent->kind                 == ENTITY_VARIABLE &&
-                                                       ent->variable.initializer != NULL            &&
-                                                       !initializer_returns(ent->variable.initializer)) {
+                                           ent->variable.initializer != NULL            &&
+                                           !initializer_returns(ent->variable.initializer)) {
                                                return;
                                        }
-                                       if (ent == last)
+                                       if (ent == last_decl)
                                                break;
                                }
                        }
@@ -7515,16 +7515,16 @@ static expression_t *parse_call_expression(expression_t *expression)
 
        /* do default promotion for other arguments */
        for (; argument != NULL; argument = argument->next) {
-               type_t *type = argument->expression->base.type;
-               if (!is_type_object(skip_typeref(type))) {
+               type_t *argument_type = argument->expression->base.type;
+               if (!is_type_object(skip_typeref(argument_type))) {
                        errorf(&argument->expression->base.source_position,
                               "call argument '%E' must not be void", argument->expression);
                }
 
-               type = get_default_promoted_type(type);
+               argument_type = get_default_promoted_type(argument_type);
 
                argument->expression
-                       = create_implicit_cast(argument->expression, type);
+                       = create_implicit_cast(argument->expression, argument_type);
        }
 
        check_format(call);
diff --git a/type.c b/type.c
index b8bab1d..c877093 100644 (file)
--- a/type.c
+++ b/type.c
@@ -191,6 +191,11 @@ static atomic_type_properties_t atomic_type_properties[ATOMIC_TYPE_LAST+1] = {
        /* complex and imaginary types are set in init_types */
 };
 
+static inline bool is_po2(unsigned x)
+{
+       return (x & (x-1)) == 0;
+}
+
 void init_types(void)
 {
        obstack_init(type_obst);
@@ -237,7 +242,9 @@ void init_types(void)
 
        if (long_double_size > 0) {
                props[ATOMIC_TYPE_LONG_DOUBLE].size      = long_double_size;
-               props[ATOMIC_TYPE_LONG_DOUBLE].alignment = long_double_size;
+               if (is_po2(long_double_size)) {
+                       props[ATOMIC_TYPE_LONG_DOUBLE].alignment = long_double_size;
+               }
        } else {
                props[ATOMIC_TYPE_LONG_DOUBLE] = props[ATOMIC_TYPE_DOUBLE];
        }
@@ -418,11 +425,11 @@ static void print_function_type_post(const function_type_t *type,
                        } else {
                                print_string(", ");
                        }
-                       const type_t *const type = parameter->declaration.type;
-                       if (type == NULL) {
+                       const type_t *const param_type = parameter->declaration.type;
+                       if (param_type == NULL) {
                                print_string(parameter->base.symbol->string);
                        } else {
-                               print_type_ext(type, parameter->base.symbol, NULL);
+                               print_type_ext(param_type, parameter->base.symbol, NULL);
                        }
                }
        }