aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2018-08-17 10:58:05 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-08-17 14:01:08 +0200
commit3bf5dcea0935b280189d04c34e84e46fb07f87e7 (patch)
treeccac207ac2a271e3f2e95298cad85504e28a02f4
parent999bea31a252dae1b0709166cf3c9540bda9dbb0 (diff)
downloadcompcert-kvx-3bf5dcea0935b280189d04c34e84e46fb07f87e7.tar.gz
compcert-kvx-3bf5dcea0935b280189d04c34e84e46fb07f87e7.zip
Check for bit-fields in __builtin_offsetof
__builtin_offsetof(struct s, f) is an error if f is a bit-field.
-rw-r--r--cparser/Elab.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 5f785c04..668b65d8 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1839,7 +1839,10 @@ let elab_expr ctx loc env a =
| _ -> fatal_error "request for member '%s' in something not a structure or union" mem in
let rec offset_of_list acc env ty = function
| [] -> acc,ty
- | fld::rest -> let off = offsetof env ty fld in
+ | fld::rest ->
+ if fld.fld_bitfield <> None then
+ error "cannot compute offset of bit-field '%s'" fld.fld_name;
+ let off = offsetof env ty fld in
offset_of_list (acc+off) env fld.fld_typ rest in
let offset_of_member (env,off_accu,ty) mem =
match mem,unroll env ty with