@@ -1462,7 +1462,7 @@ let arithmeticConversion (* c.f. ISO 6.3.1.8 *)
14621462
14631463
14641464(* Specify whether the cast is from the source code *)
1465- let rec castTo ?( kind = Unknown )
1465+ let rec castTo ~ kind
14661466 (ot : typ ) (nt : typ ) (e : exp ) : (typ * exp ) =
14671467 let fromsource =
14681468 match kind with
@@ -3500,7 +3500,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
35003500 (SynthetizeLoc. doChunkTail se, e, t)
35013501 | _ ->
35023502 let (e', t') = processArrayFun e t in
3503- let (t'', e'') = castTo t' lvt e' in
3503+ let (t'', e'') = castTo ~kind: Unknown t' lvt e' in
35043504(*
35053505 ignore (E.log "finishExp: e = %a\n e'' = %a\n" d_plainexp e d_plainexp e'');
35063506*)
@@ -4280,7 +4280,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
42804280 let tresult, result = doBinOp bop' e1' t1 e2' t2 in
42814281 (* We must cast the result to the type of the lv1, which may be
42824282 different than t1 if lv1 was a Cast *)
4283- let tresult', result' = castTo tresult (typeOfLval lv1) result in
4283+ let tresult', result' = castTo ~kind: Unknown tresult (typeOfLval lv1) result in
42844284 (* Catch the case of an lval that might depend on itself,
42854285 e.g. p[p[0]] when p[0] == 0. We need to use a temporary
42864286 here if the result of the expression will be used:
@@ -4322,7 +4322,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
43224322 | CEExp (se , e ) ->
43234323 let e' =
43244324 let te = typeOf e in
4325- let _, zte = castTo intType te zero in
4325+ let _, zte = castTo ~kind: Unknown intType te zero in
43264326 BinOp (Ne , e, zte, intType)
43274327 in
43284328 finishExp se e' intType
@@ -4445,7 +4445,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
44454445 test/small1/union5, in which a transparent union is passed
44464446 as an argument *)
44474447 let (sa, a', att) = force_right_to_left_evaluation (doExp false a (AExp None )) in
4448- let (_, a'') = castTo att at a' in
4448+ let (_, a'') = castTo ~kind: Unknown att at a' in
44494449 (sa :: ss, a'' :: args')
44504450 | ([] , args ) -> (* No more types *)
44514451 (* Do not give a warning for functions without a prototype*)
@@ -4463,7 +4463,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
44634463 (sa :: ss, a' :: args')
44644464 else
44654465 let promoted_type = defaultArgumentPromotion at in
4466- let _, a'' = castTo at promoted_type a' in
4466+ let _, a'' = castTo ~kind: Unknown at promoted_type a' in
44674467 (sa :: ss, a'' :: args')
44684468 in
44694469 loop args
@@ -4838,23 +4838,23 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48384838 let tresult = conditionalConversion t2 t3 e_of_t2 e3' in
48394839 match ce1 with
48404840 CEExp (se1 , e1' ) when isConstFalse e1' && canDrop se2 && (! Cil. removeBranchingOnConstants || asconst) ->
4841- finishExp (se1 @@ se3) (snd (castTo t3 tresult e3')) tresult
4841+ finishExp (se1 @@ se3) (snd (castTo ~kind: Unknown t3 tresult e3')) tresult
48424842 | CEExp (se1 , e1' ) when isConstTrue e1' && canDrop se3 && (! Cil. removeBranchingOnConstants || asconst) ->
48434843 begin
48444844 match e2'o with
48454845 None -> (* use e1' *)
4846- finishExp (se1 @@ se2) (snd (castTo t2 tresult e1')) tresult
4846+ finishExp (se1 @@ se2) (snd (castTo ~kind: Unknown t2 tresult e1')) tresult
48474847 | Some e2' ->
4848- finishExp (se1 @@ se2) (snd (castTo t2 tresult e2')) tresult
4848+ finishExp (se1 @@ se2) (snd (castTo ~kind: Unknown t2 tresult e2')) tresult
48494849 end
48504850 | CEExp (se1 , e1' ) when ! useLogicalOperators && isEmpty se2 && isEmpty se3 ->
48514851 let e2' = match e2'o with
48524852 None -> (* use e1' *)
4853- snd (castTo t2 tresult e1')
4853+ snd (castTo ~kind: Unknown t2 tresult e1')
48544854 | Some e2' ->
4855- snd (castTo t2 tresult e2')
4855+ snd (castTo ~kind: Unknown t2 tresult e2')
48564856 in
4857- let e3' = snd (castTo t3 tresult e3') in
4857+ let e3' = snd (castTo ~kind: Unknown t3 tresult e3') in
48584858 finishExp se1 (Question (e1', e2', e3', tresult)) tresult
48594859 | _ -> (* Use a conditional *) begin
48604860 match e2'o with
@@ -6675,7 +6675,7 @@ and assignInit (lv: lval)
66756675 (acc : chunk ) : chunk =
66766676 match ie with
66776677 SingleInit e ->
6678- let (_, e'') = castTo iet (typeOfLval lv) e in
6678+ let (_, e'') = castTo ~kind: Unknown iet (typeOfLval lv) e in
66796679 acc +++ (Set (lv, e'', ! currentLoc, ! currentExpLoc))
66806680 | CompoundInit (t , initl ) -> begin
66816681 match unrollType t with
@@ -6892,7 +6892,7 @@ and doStatement (s : A.statement) : chunk =
68926892 typeRemoveAttributes [" warn_unused_result" ] ! currentReturnType
68936893 in
68946894 let (se, e', et) = doExp false e (AExp (Some rt)) in
6895- let (et'', e'') = castTo et rt e' in
6895+ let (et'', e'') = castTo ~kind: Unknown et rt e' in
68966896 se @@ (returnChunk (Some e'') loc' eloc')
68976897 end
68986898
0 commit comments