diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-03-23 10:17:10 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-03-23 10:17:10 +0000 |
commit | 0a9e21307d3abd1612bc95f9552dc2fe110742b5 (patch) | |
tree | d3d88af20c950a73d10673fbb645cdfdcdcdb661 /cfrontend/PrintClight.ml | |
parent | e57315d524658bcde314785bcf30780f2361e359 (diff) | |
download | compcert-0a9e21307d3abd1612bc95f9552dc2fe110742b5.tar.gz compcert-0a9e21307d3abd1612bc95f9552dc2fe110742b5.zip |
Watch out for behaviors exponential in the nesting of struct/union types.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2158 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/PrintClight.ml')
-rw-r--r-- | cfrontend/PrintClight.ml | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/cfrontend/PrintClight.ml b/cfrontend/PrintClight.ml index 7653f0c2..d61afa3d 100644 --- a/cfrontend/PrintClight.ml +++ b/cfrontend/PrintClight.ml @@ -26,18 +26,6 @@ open Cop open PrintCsyntax open Clight -(* Collecting the names and fields of structs and unions *) - -module StructUnionSet = Set.Make(struct - type t = string * fieldlist - let compare (n1, _ : t) (n2, _ : t) = compare n1 n2 -end) - -let struct_unions = ref StructUnionSet.empty - -let register_struct_union id fld = - struct_unions := StructUnionSet.add (extern_atom id, fld) !struct_unions - (* Naming temporaries *) let temp_name (id: ident) = "$" ^ Z.to_string (Z.Zpos id) @@ -320,25 +308,12 @@ let collect_globdef (id, gd) = let collect_program p = List.iter collect_globdef p.prog_defs -let declare_struct_or_union p (name, fld) = - fprintf p "%s;@ @ " name - -let print_struct_or_union p (name, fld) = - fprintf p "@[<v 2>%s {" name; - let rec print_fields = function - | Fnil -> () - | Fcons(id, ty, rem) -> - fprintf p "@ %s;" (name_cdecl (extern_atom id) ty); - print_fields rem in - print_fields fld; - fprintf p "@;<0 -2>};@]@ @ " - let print_program p prog = - struct_unions := StructUnionSet.empty; + struct_unions := StructUnion.empty; collect_program prog; fprintf p "@[<v 0>"; - StructUnionSet.iter (declare_struct_or_union p) !struct_unions; - StructUnionSet.iter (print_struct_or_union p) !struct_unions; + StructUnion.iter (declare_struct_or_union p) !struct_unions; + StructUnion.iter (print_struct_or_union p) !struct_unions; List.iter (print_globdef p) prog.prog_defs; fprintf p "@]@." |