From ac2e4bb9bc63e0ea8b5cf67274bddb9ec74b771e Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 20 Jan 2017 12:05:15 +0100 Subject: Also support union. Bug 20765 --- cparser/Elab.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cparser') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index d8d1d7d2..afdf3969 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -1644,11 +1644,12 @@ let elab_expr vararg loc env a = | BUILTIN_OFFSETOF ((spec,dcl), mem) -> let (ty,env) = elab_type loc env spec dcl in + if Cutil.incomplete_type env ty then + error "offsetof of incomplete type %a" (print_typ env) ty; let offset = match unroll env ty with - | TStruct(id, attrs) -> - if Cutil.incomplete_type env ty then - error "offsetof of incomplete type %a" (print_typ env) ty; + | TStruct(id,_) + | TUnion (id,_)-> let fld = (wrap Env.find_struct_member loc env (id,mem)) in if List.exists (fun fld -> fld.fld_bitfield <> None) fld then error "cannot compute the offset of bitfield '%s" mem; -- cgit