@@ -418,7 +418,17 @@ let is_longlong ik =
418418 match ik with ILongLong | IULongLong -> true | _ -> false
419419
420420
421- (* * {1 Integer promotion: C Standard 6.3.1.8}
421+ (* * {1 Integer promotion: C Standard 6.3.1.1, 6.3.1.8}
422+
423+ The following may be used in an expression wherever an int or unsigned
424+ int may be used:
425+ - an object or expression with an integer type whose integer conversion
426+ rank is less than or equal to the rank of int and unsigned int.
427+ - a bit-field of type _Bool, int, signed int, unsigned int.
428+
429+ If an int can represent all values of the original type, the value is
430+ converted to an int; otherwise it is converted to an unsigned int. These
431+ are called the integer promotions. A
422432
423433 First, both types are promoted to either signed or unsigned int.
424434
@@ -442,21 +452,21 @@ let is_longlong ik =
442452 corresponding to the type of the operand with signed integer type.
443453 *)
444454
445- let get_integer_promotion (ty1 :typ ) (ty2 :typ ) =
455+ let get_integer_promotion (ty1 : typ ) (ty2 : typ ) =
446456 let promote ik =
447457 match ik with
448- | IChar | ISChar | IShort -> IInt
449- | IUChar | IUShort -> IUInt
458+ | IChar | ISChar | IUChar | IShort | IBool -> IInt
459+ | IUShort -> IUInt
450460 | _ -> ik in
451- let ik = match (ty1,ty2) with
452- | (TInt (ik1 ,_ ), TInt (ik2 ,_ )) ->
461+ let ik = match (ty1, ty2) with
462+ | (TInt (ik1 , _ ), TInt (ik2 , _ )) ->
453463 let ik1 = promote ik1 in
454464 let ik2 = promote ik2 in
455465 if ik1 = ik2 then
456466 ik1
457467 else
458468 begin
459- match (ik1,ik2) with
469+ match (ik1, ik2) with
460470 | (IInt , ILong ) | (ILong, IInt) -> ILong
461471 | (IInt , ILongLong ) | (ILongLong, IInt) -> ILongLong
462472 | (ILong , ILongLong ) | (ILongLong, ILong) -> ILongLong
0 commit comments