summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cfrontend/C2C.ml6
-rw-r--r--cparser/PackedStructs.ml11
2 files changed, 12 insertions, 5 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index 45ff80f..16c85ed 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -836,8 +836,10 @@ let convertGlobvar loc env (sto, id, ty, optinit) =
let checkComposite env si id attr flds =
let checkField f =
if f.fld_bitfield <> None then
- unsupported "bit field in struct or union (consider adding option -fbitfields)"
- in List.iter checkField flds
+ unsupported "bit field in struct or union (consider adding option -fbitfields)" in
+ List.iter checkField flds;
+ if Cutil.find_custom_attributes ["packed";"__packed__"] attr <> [] then
+ unsupported "packed struct (consider adding option -fpacked-struct)"
(** Convert a list of global declarations.
Result is a list of CompCert C global declarations (functions +
diff --git a/cparser/PackedStructs.ml b/cparser/PackedStructs.ml
index 6d184a6..41c00ba 100644
--- a/cparser/PackedStructs.ml
+++ b/cparser/PackedStructs.ml
@@ -119,7 +119,8 @@ let transf_composite loc env su id attrs ml =
(0L, 0L, false) in
let mfa = packed_param_value loc mfa in
let msa = packed_param_value loc msa in
- transf_struct_decl mfa msa swapped loc env id attrs ml
+ let attrs' = remove_custom_attributes ["packed";"__packed__"] attrs in
+ transf_struct_decl mfa msa swapped loc env id attrs' ml
(* Accessor functions *)
@@ -391,9 +392,13 @@ let rec transf_globdecls env accu = function
({g with gdesc = Gfundef(transf_fundef env f)} :: accu)
gl
| Gcompositedecl(su, id, attr) ->
+ let attr' =
+ match su with
+ | Union -> attr
+ | Struct -> remove_custom_attributes ["packed";"__packed__"] attr in
transf_globdecls
- (Env.add_composite env id (composite_info_decl env su attr))
- (g :: accu)
+ (Env.add_composite env id (composite_info_decl env su attr'))
+ ({g with gdesc = Gcompositedecl(su, id, attr')} :: accu)
gl
| Gcompositedef(su, id, attr, fl) ->
let (attr', fl') = transf_composite g.gloc env su id attr fl in