diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-03-07 13:10:47 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-03-07 13:10:47 +0000 |
commit | 8a26cc219f8c8211301f021bd0ee4a27153528f8 (patch) | |
tree | 8bb47160ac9b5da23e54b33ac43f722ba09c094b /cfrontend | |
parent | fdcaf6fabd3d594e40a2b7a31341202e9a93f5cb (diff) |
Cprint: export Cprint.attributes
PackedStructs: honor 'aligned' attribute on packed struct fields
C2C: warn for ignored 'aligned' attributes
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1837 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend')
-rw-r--r-- | cfrontend/C2C.ml | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index 1a2a453..14e345b 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -342,8 +342,6 @@ let convertTyp env t = and convertFieldList seen = function | [] -> Fnil | f :: fl -> - if f.fld_bitfield <> None then - unsupported "bit field in struct or union"; Fcons(intern_string f.fld_name, convertTyp seen f.fld_typ, convertFieldList seen fl) @@ -784,6 +782,17 @@ let convertGlobvar env (sto, id, ty, optinit) = (id', {gvar_info = ty'; gvar_init = init'; gvar_readonly = readonly; gvar_volatile = volatile}) +(** Sanity checks on composite declarations. *) + +let checkComposite env si id attr flds = + let checkField f = + if f.fld_bitfield <> None then + unsupported "bit field in struct or union"; + if Cutil.find_custom_attributes ["aligned"; "__aligned__"] + (Cutil.attributes_of_type env f.fld_typ) <> [] then + warning ("ignoring 'aligned' attribute on field " ^ f.fld_name) + in List.iter checkField flds + (** Convert a list of global declarations. Result is a pair [(funs, vars)] where [funs] are the function definitions (internal and external) @@ -812,11 +821,14 @@ let rec convertGlobdecls env funs vars gl = end | C.Gfundef fd -> convertGlobdecls env (convertFundef env fd :: funs) vars gl' - | C.Gcompositedecl _ | C.Gcompositedef _ - | C.Gtypedef _ | C.Genumdef _ -> + | C.Gcompositedecl _ | C.Gtypedef _ | C.Genumdef _ -> (* typedefs are unrolled, structs are expanded inline, and enum tags are folded. So we just skip their declarations. *) convertGlobdecls env funs vars gl' + | C.Gcompositedef(su, id, attr, flds) -> + (* sanity checks on fields *) + checkComposite env su id attr flds; + convertGlobdecls env funs vars gl' | C.Gpragma s -> if not (!process_pragma_hook s) then warning ("'#pragma " ^ s ^ "' directive ignored"); |