@@ -94,9 +94,9 @@ static long long get_longlong(struct expression *expr)
9494 return (value & andmask ) | ormask ;
9595}
9696
97- void cast_value (struct expression * expr , struct symbol * newtype ,
98- struct expression * old , struct symbol * oldtype )
97+ void cast_value (struct expression * expr , struct symbol * newtype , struct expression * old )
9998{
99+ struct symbol * oldtype = old -> ctype ;
100100 int old_size = oldtype -> bit_size ;
101101 int new_size = newtype -> bit_size ;
102102 long long value , mask , signmask ;
@@ -110,11 +110,13 @@ void cast_value(struct expression *expr, struct symbol *newtype,
110110 expr -> taint = old -> taint ;
111111 if (old_size == new_size ) {
112112 expr -> value = old -> value ;
113+ expr -> ctype = newtype ;
113114 return ;
114115 }
115116
116117 // expand it to the full "long long" value
117118 value = get_longlong (old );
119+ expr -> ctype = newtype ;
118120
119121Int :
120122 // _Bool requires a zero test rather than truncation.
@@ -153,6 +155,7 @@ void cast_value(struct expression *expr, struct symbol *newtype,
153155 value = (long long )old -> fvalue ;
154156 expr -> type = EXPR_VALUE ;
155157 expr -> taint = 0 ;
158+ expr -> ctype = newtype ;
156159 goto Int ;
157160 }
158161
@@ -168,6 +171,7 @@ void cast_value(struct expression *expr, struct symbol *newtype,
168171 expr -> fvalue = (float )expr -> fvalue ;
169172 }
170173 expr -> type = EXPR_FVALUE ;
174+ expr -> ctype = newtype ;
171175}
172176
173177/* Return true if constant shift size is valid */
@@ -872,7 +876,7 @@ static int expand_cast(struct expression *expr)
872876
873877 /* Simplify normal integer casts.. */
874878 if (target -> type == EXPR_VALUE || target -> type == EXPR_FVALUE ) {
875- cast_value (expr , expr -> ctype , target , target -> ctype );
879+ cast_value (expr , expr -> ctype , target );
876880 return 0 ;
877881 }
878882 return cost + 1 ;
0 commit comments