From 5ed9453be66703578f260450e4dde0b5a7125113 Mon Sep 17 00:00:00 2001 From: xleroy Date: Fri, 4 Oct 2013 13:15:01 +0000 Subject: Elab: - bad error recovery on bitfield with 'long long' type - check for redefinition of function parameters Bitfields: - when assigning to a bitfield, cast the RHS to "unsigned int" (it matters if the RHS is long long). git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2339 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/Bitfields.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cparser/Bitfields.ml') diff --git a/cparser/Bitfields.ml b/cparser/Bitfields.ml index 937a61f3..d09c1fef 100644 --- a/cparser/Bitfields.ml +++ b/cparser/Bitfields.ml @@ -183,15 +183,13 @@ let bitfield_extract bf carrier = {edesc = EBinop(Oshl, carrier, left_shift_count bf, TInt(IUInt, [])); etyp = carrier.etyp} in let ty = TInt((if bf.bf_signed then IInt else IUInt), []) in - let e2 = - {edesc = ECast(ty, e1); etyp = ty} in + let e2 = ecast ty e1 in let e3 = {edesc = EBinop(Oshr, e2, right_shift_count bf, e2.etyp); etyp = ty} in - if bf.bf_signed_res = bf.bf_signed then e3 else begin - let ty' = TInt((if bf.bf_signed_res then IInt else IUInt), []) in - {edesc = ECast(ty', e3); etyp = ty'} - end + if bf.bf_signed_res = bf.bf_signed + then e3 + else ecast (TInt((if bf.bf_signed_res then IInt else IUInt), [])) e3 (* Assign a bitfield within a carrier *) @@ -208,8 +206,10 @@ unsigned int bitfield_insert(unsigned int x, int ofs, int sz, unsigned int y) let bitfield_assign bf carrier newval = let msk = insertion_mask bf in let notmsk = {edesc = EUnop(Onot, msk); etyp = msk.etyp} in + let newval_casted = + ecast (TInt(IUInt,[])) newval in let newval_shifted = - {edesc = EBinop(Oshl, newval, intconst (Int64.of_int bf.bf_pos) IUInt, + {edesc = EBinop(Oshl, newval_casted, intconst (Int64.of_int bf.bf_pos) IUInt, TInt(IUInt,[])); etyp = TInt(IUInt,[])} in let newval_masked = -- cgit