From fbc778079d50a4af45b9a648eab56cef29ac75f4 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 27 Mar 2018 17:15:42 +0200 Subject: Sizeof and _Alignof are not allowed on bit-fields (#67) Sizeof and _Alignof are not allowed on bit-fields Sizeof and _Alignof are not allowed to be applied to a expression that designates a bit-field member. Bug 23311 --- cparser/Cutil.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cparser/Cutil.ml') diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 30037049..4a5c9427 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -988,6 +988,16 @@ let is_call_to_fun e s = | EVar id -> id.C.name = s | _ -> false +let is_bitfield env e = + match e.edesc with + | EUnop(Odot f,b) -> + let fld = field_of_dot_access env b.etyp f in + fld.fld_bitfield <> None + | EUnop(Oarrow f,b) -> + let fld = field_of_arrow_access env b.etyp f in + fld.fld_bitfield <> None + | _ -> false + (* Assignment compatibility check over attributes. Standard attributes ("const", "volatile", "restrict") can safely be added (to the rhs type to get the lhs type) but must not be dropped. -- cgit