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/Initializers.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cfrontend/Initializers.v') diff --git a/cfrontend/Initializers.v b/cfrontend/Initializers.v index 8757ba2e..7711adea 100644 --- a/cfrontend/Initializers.v +++ b/cfrontend/Initializers.v @@ -151,10 +151,12 @@ Definition transl_init_single (ty: type) (a: expr) : res init_data := | Vint n, Tint I16 sg _ => OK(Init_int16 n) | Vint n, Tint I32 sg _ => OK(Init_int32 n) | Vint n, Tpointer _ _ => OK(Init_int32 n) + | Vint n, Tcomp_ptr _ _ => OK(Init_int32 n) | Vfloat f, Tfloat F32 _ => OK(Init_float32 f) | Vfloat f, Tfloat F64 _ => OK(Init_float64 f) | Vptr (Zpos id) ofs, Tint I32 sg _ => OK(Init_addrof id ofs) | Vptr (Zpos id) ofs, Tpointer _ _ => OK(Init_addrof id ofs) + | Vptr (Zpos id) ofs, Tcomp_ptr _ _ => OK(Init_addrof id ofs) | Vundef, _ => Error(msg "undefined operation in initializer") | _, _ => Error (msg "type mismatch in initializer") end. @@ -208,7 +210,7 @@ with transl_init_struct (id: ident) (ty: type) OK (padding pos (sizeof ty)) | Init_cons i1 il', Fcons _ ty1 fl' => let pos1 := align pos (alignof ty1) in - do d1 <- transl_init (unroll_composite id ty ty1) i1; + do d1 <- transl_init ty1 i1; do d2 <- transl_init_struct id ty fl' il' (pos1 + sizeof ty1); OK (padding pos pos1 ++ d1 ++ d2) | _, _ => @@ -221,7 +223,7 @@ with transl_init_union (id: ident) (ty ty1: type) (il: initializer_list) | Init_nil => Error (msg "empty union initializer") | Init_cons i1 _ => - do d <- transl_init (unroll_composite id ty ty1) i1; + do d <- transl_init ty1 i1; OK (d ++ padding (sizeof ty1) (sizeof ty)) end. -- cgit