Print this page
new smatch

@@ -191,11 +191,10 @@
 static const char *current_section;
 
 static void emit_comment(const char * fmt, ...) FORMAT_ATTR(1);
 static void emit_move(struct storage *src, struct storage *dest,
                       struct symbol *ctype, const char *comment);
-static int type_is_signed(struct symbol *sym);
 static struct storage *x86_address_gen(struct expression *expr);
 static struct storage *x86_symbol_expr(struct symbol *sym);
 static void x86_symbol(struct symbol *sym);
 static struct storage *x86_statement(struct statement *stmt);
 static struct storage *x86_expression(struct expression *expr);

@@ -450,11 +449,11 @@
                 break;
         case STOR_REG:
                 strcpy(name, s->reg->name);
                 break;
         case STOR_VALUE:
-                sprintf(name, "$%Ld", s->value);
+                sprintf(name, "$%lld", s->value);
                 break;
         case STOR_LABEL:
                 sprintf(name, "%s.L%d", s->flags & STOR_LABEL_VAL ? "$" : "",
                         s->label);
                 break;

@@ -935,11 +934,11 @@
         default:        type = NULL;    break;
         }
 
         assert(type != NULL);
 
-        printf("\t.%s\t%Ld\n", type, ll);
+        printf("\t.%s\t%lld\n", type, ll);
 }
 
 static void emit_global_noinit(const char *name, unsigned long modifiers,
                                unsigned long alignment, unsigned int byte_size)
 {

@@ -1161,11 +1160,11 @@
         unsigned int is_dest = (src->type == STOR_REG);
         const char *opname;
 
         if (ctype) {
                 bits = ctype->bit_size;
-                is_signed = type_is_signed(ctype);
+                is_signed = is_signed_type(ctype);
         } else {
                 bits = 32;
                 is_signed = 0;
         }
 

@@ -1353,11 +1352,11 @@
 
         /* Divides have special register constraints */
         if ((expr->op == '/') || (expr->op == '%'))
                 return emit_divide(expr, left, right);
 
-        is_signed = type_is_signed(expr->ctype);
+        is_signed = is_signed_type(expr->ctype);
 
         switch (expr->op) {
         case '+':
                 opname = "add";
                 break;

@@ -1553,29 +1552,29 @@
         return val;
 }
 
 static struct storage *emit_conditional_expr(struct expression *expr)
 {
-        struct storage *cond, *true = NULL, *false = NULL;
+        struct storage *cond, *stot = NULL, *stof = NULL;
         struct storage *new = stack_alloc(expr->ctype->bit_size / 8);
         int target_false, cond_end;
 
         /* evaluate conditional */
         cond = x86_expression(expr->conditional);
         target_false = emit_conditional_test(cond);
 
         /* handle if-true part of the expression */
-        true = x86_expression(expr->cond_true);
+        stot = x86_expression(expr->cond_true);
 
-        emit_copy(new, true, expr->ctype);
+        emit_copy(new, stot, expr->ctype);
 
         cond_end = emit_conditional_end(target_false);
 
         /* handle if-false part of the expression */
-        false = x86_expression(expr->cond_false);
+        stof = x86_expression(expr->cond_false);
 
-        emit_copy(new, false, expr->ctype);
+        emit_copy(new, stof, expr->ctype);
 
         /* end of conditional; jump target for if-true branch */
         emit_label(cond_end, "end conditional");
 
         return new;

@@ -1582,19 +1581,19 @@
 }
 
 static struct storage *emit_select_expr(struct expression *expr)
 {
         struct storage *cond = x86_expression(expr->conditional);
-        struct storage *true = x86_expression(expr->cond_true);
-        struct storage *false = x86_expression(expr->cond_false);
+        struct storage *stot = x86_expression(expr->cond_true);
+        struct storage *stof = x86_expression(expr->cond_false);
         struct storage *reg_cond, *reg_true, *reg_false;
         struct storage *new = stack_alloc(4);
 
         emit_comment("begin SELECT");
         reg_cond = get_reg_value(cond, get_regclass(expr->conditional));
-        reg_true = get_reg_value(true, get_regclass(expr));
-        reg_false = get_reg_value(false, get_regclass(expr));
+        reg_true = get_reg_value(stot, get_regclass(expr));
+        reg_false = get_reg_value(stof, get_regclass(expr));
 
         /*
          * Do the actual select: check the conditional for zero,
          * move false over true if zero
          */ 

@@ -2234,11 +2233,11 @@
         if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) {
                 printf("\tmovi.%d\t\tv%d,$%s\n", bits_in_pointer, new->pseudo, show_ident(sym->ident));
                 return new;
         }
         if (sym->ctype.modifiers & MOD_ADDRESSABLE) {
-                printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new->pseudo, sym->value);
+                printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new->pseudo, 0LL);
                 return new;
         }
         printf("\taddi.%d\t\tv%d,vFP,$offsetof(%s:%p)\n", bits_in_pointer, new->pseudo, show_ident(sym->ident), sym);
         return new;
 }

@@ -2262,19 +2261,10 @@
         }
 
         priv->addr = new;
 }
 
-static int type_is_signed(struct symbol *sym)
-{
-        if (sym->type == SYM_NODE)
-                sym = sym->ctype.base_type;
-        if (sym->type == SYM_PTR)
-                return 0;
-        return !(sym->ctype.modifiers & MOD_UNSIGNED);
-}
-
 static struct storage *x86_label_expr(struct expression *expr)
 {
         struct storage *new = stack_alloc(4);
         printf("\tmovi.%d\t\tv%d,.L%p\n", bits_in_pointer, new->pseudo, expr->label_symbol);
         return new;