From be43363d309cea62731e04ad10dddf3ecafcacd1 Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 11 Sep 2006 16:03:02 +0000 Subject: Revu traitement des structures et unions recursives. Dans Cshmgen, meilleure compilation de exit_if_false. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@94 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- caml/Cil2Csyntax.ml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'caml/Cil2Csyntax.ml') diff --git a/caml/Cil2Csyntax.ml b/caml/Cil2Csyntax.ml index 779929cf..de0b6165 100644 --- a/caml/Cil2Csyntax.ml +++ b/caml/Cil2Csyntax.ml @@ -345,7 +345,7 @@ and convertLval lv = | NoOffset -> e | Field (f, ofs) -> begin match t with - | Tstruct fList -> + | Tstruct(_, fList) -> begin try let idf = intern_string f.fname in let t' = getFieldType idf fList in @@ -353,7 +353,7 @@ and convertLval lv = with Not_found -> internal_error "processOffset: no such struct field" end - | Tunion fList -> + | Tunion(_, fList) -> begin try let idf = intern_string f.fname in let t' = getFieldType idf fList in @@ -399,6 +399,8 @@ and convertTypGen env = function | TVoid _ -> Tvoid | TInt (k, _) -> let (x, y) = convertIkind k in Tint (x, y) | TFloat (k, _) -> Tfloat (convertFkind k) + | TPtr (TComp(c, _), _) when List.mem c.ckey env -> + Tcomp_ptr (intern_string (Cil.compFullName c)) | TPtr (t, _) -> Tpointer (convertTypGen env t) | TArray (t, eOpt, _) -> begin match eOpt with @@ -423,7 +425,9 @@ and convertTypGen env = function end | TNamed (tinfo, _) -> convertTypGen env tinfo.ttype | TComp (c, _) -> - if List.mem c.ckey env then Tvoid else begin + if List.mem c.ckey env then + unsupported "ill-formed recursive structure or union" + else begin let rec convertFieldList = function | [] -> Fnil | {fname=str; ftype=t} :: rem -> @@ -431,7 +435,8 @@ and convertTypGen env = function let t' = convertTypGen (c.ckey :: env) t in Fcons(idf, t', convertFieldList rem) in let fList = convertFieldList c.cfields in - if c.cstruct then Tstruct fList else Tunion fList + let id = intern_string (Cil.compFullName c) in + if c.cstruct then Tstruct(id, fList) else Tunion(id, fList) end | TEnum _ -> constInt32 (* enum constants are integers *) | TBuiltin_va_list _ -> unsupported "GCC `builtin va_list' type" -- cgit