From 0a9e21307d3abd1612bc95f9552dc2fe110742b5 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 23 Mar 2013 10:17:10 +0000 Subject: 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 --- cfrontend/PrintClight.ml | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'cfrontend/PrintClight.ml') diff --git a/cfrontend/PrintClight.ml b/cfrontend/PrintClight.ml index 7653f0c..d61afa3 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 "@[%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 "@["; - 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 "@]@." -- cgit v1.2.3