From 98089fdf4880b46a57aafa96ea00578e396bb58b Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 30 Dec 2013 14:01:44 +0000 Subject: Elab.ml: more warnings. Cutil.ml: fix sizeof calculation of structs. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2391 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/Cutil.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cparser/Cutil.ml') diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index ea4a905d..302c1cfe 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -397,9 +397,14 @@ let sizeof_union env members = let sizeof_struct env members = let rec sizeof_rec ofs = function - | [] | [ { fld_typ = TArray(_, None, _) } ] -> - (* C99: ty[] allowed as last field *) + | [] -> Some ofs + | [ { fld_typ = TArray(_, None, _) } as m ] -> + (* C99: ty[] allowed as last field *) + begin match alignof env m.fld_typ with + | Some a -> Some (align ofs a) + | None -> None + end | m :: rem as ml -> if m.fld_bitfield = None then begin match alignof env m.fld_typ, sizeof env m.fld_typ with -- cgit