Skip to content

Commit e8211d7

Browse files
committed
Add missing integer promotion to unary plus
1 parent a66f972 commit e8211d7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/frontc/cabs2cil.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,8 +4020,17 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
40204020
else
40214021
E.s (error "Unary ~ on a non-integral type")
40224022

4023-
| A.UNARY(A.PLUS, e) -> doExp asconst e what
4024-
4023+
| A.UNARY(A.PLUS, e) ->
4024+
let (se, e', t) = doExp asconst e (AExp None) in
4025+
if isIntegralType t then
4026+
let tres = integralPromotion t in
4027+
let e'' = makeCastT ~e:e' ~oldt:t ~newt:tres in
4028+
finishExp se e'' tres
4029+
else
4030+
if isArithmeticType t then
4031+
finishExp se e' t
4032+
else
4033+
E.s (error "Unary + on a non-arithmetic type")
40254034

40264035
| A.UNARY(A.ADDROF, e) -> begin
40274036
match e with

0 commit comments

Comments
 (0)