aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/Initializers.v
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-03-23 10:17:10 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-03-23 10:17:10 +0000
commit0a9e21307d3abd1612bc95f9552dc2fe110742b5 (patch)
treed3d88af20c950a73d10673fbb645cdfdcdcdb661 /cfrontend/Initializers.v
parente57315d524658bcde314785bcf30780f2361e359 (diff)
downloadcompcert-kvx-0a9e21307d3abd1612bc95f9552dc2fe110742b5.tar.gz
compcert-kvx-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/Initializers.v')
-rw-r--r--cfrontend/Initializers.v6
1 files changed, 4 insertions, 2 deletions
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.