@@ -1911,29 +1911,19 @@ let conditionalConversion (t2: typ) (t3: typ) (e2: exp option) (e3:exp) : typ =
19111911 arithmeticConversion t2 t3
19121912 | TComp (comp2,_), TComp (comp3,_), _
19131913 when comp2.ckey = comp3.ckey -> t2
1914- | TPtr (b2 , _ ), TPtr (TVoid a3 , _ ) , _ ->
1915- if isNullPtrConstant e3 then
1916- t2
1917- else (
1914+ | TPtr (_ , _ ), _ , _ when isNullPtrConstant e3 -> t2
1915+ | _ , TPtr ( _ , _ ), Some e2' when isNullPtrConstant e2' -> t3
1916+ | TPtr (b2, _), TPtr ( TVoid _ as b3, _), _
1917+ | TPtr (TVoid _ as b2 , _ ), TPtr ( b3 , _ ), _ ->
19181918 let a2 = typeAttrsOuter b2 in
1919- let (q2, _) = partitionQualifierAttributes a2 in
1920- let (q3, _) = partitionQualifierAttributes a3 in
1921- let q = cabsAddAttributes q2 q3 in
1922- TPtr (TVoid q, [] )
1923- )
1924- | TPtr (TVoid a2 , _ ), TPtr (b3 , _ ), Some e2' ->
1925- if isNullPtrConstant e2' then
1926- t3
1927- else (
19281919 let a3 = typeAttrsOuter b3 in
19291920 let (q2, _) = partitionQualifierAttributes a2 in
19301921 let (q3, _) = partitionQualifierAttributes a3 in
19311922 let q = cabsAddAttributes q2 q3 in
19321923 TPtr (TVoid q, [] )
1933- )
19341924 | TPtr _ , TPtr _ , _ when Util. equals (typeSig t2) (typeSig t3) -> t2
1935- | TPtr _ , TInt _ , _ -> t2 (* most likely comparison with int constant 0, if it isn't it would not be valid C *)
1936- | TInt _ , TPtr _ , _ -> t3 (* most likely comparison with int constant 0, if it isn't it would not be valid C *)
1925+ | TPtr _ , TInt _ , _ -> t2 (* not "null pointer constant", not allowed by standard, works in gcc/clang with warning *)
1926+ | TInt _ , TPtr _ , _ -> t3 (* not "null pointer constant", not allowed by standard, works in gcc/clang with warning *)
19371927
19381928 (* When we compare two pointers of different type, we combine them
19391929 * using the same algorithm when combining multiple declarations of
0 commit comments