diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-20 12:05:15 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-20 12:05:15 +0100 |
commit | ac2e4bb9bc63e0ea8b5cf67274bddb9ec74b771e (patch) | |
tree | 87b19e1f25989338f11c679c6f5ddda4dcde09f4 | |
parent | 55937c177f90ecf0dea40c318d2f8d52fa69b55d (diff) | |
download | compcert-ac2e4bb9bc63e0ea8b5cf67274bddb9ec74b771e.tar.gz compcert-ac2e4bb9bc63e0ea8b5cf67274bddb9ec74b771e.zip |
Also support union. Bug 20765
-rw-r--r-- | cparser/Elab.ml | 7 |
1 files changed, 4 insertions, 3 deletions
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; |