diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-09-11 16:03:02 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-09-11 16:03:02 +0000 |
commit | be43363d309cea62731e04ad10dddf3ecafcacd1 (patch) | |
tree | f66c346d51df74d6b6ee34f654178a44250a33c8 /caml/Cil2Csyntax.ml | |
parent | 5e8237152cad0cf08d3eea0d5de8cd8bc499df69 (diff) | |
download | compcert-be43363d309cea62731e04ad10dddf3ecafcacd1.tar.gz compcert-be43363d309cea62731e04ad10dddf3ecafcacd1.zip |
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
Diffstat (limited to 'caml/Cil2Csyntax.ml')
-rw-r--r-- | caml/Cil2Csyntax.ml | 13 |
1 files changed, 9 insertions, 4 deletions
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" |