aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Bitfields.ml
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-10-04 13:15:01 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-10-04 13:15:01 +0000
commit5ed9453be66703578f260450e4dde0b5a7125113 (patch)
treef76401c06d06f8976dfd7bca67ca6d0260aaaabd /cparser/Bitfields.ml
parent364176f170cf4b5e554cb62b4fedb86cfc0d52c3 (diff)
downloadcompcert-5ed9453be66703578f260450e4dde0b5a7125113.tar.gz
compcert-5ed9453be66703578f260450e4dde0b5a7125113.zip
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
Diffstat (limited to 'cparser/Bitfields.ml')
-rw-r--r--cparser/Bitfields.ml14
1 files changed, 7 insertions, 7 deletions
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 =