aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/C2C.ml
diff options
context:
space:
mode:
Diffstat (limited to 'cfrontend/C2C.ml')
-rw-r--r--cfrontend/C2C.ml18
1 files changed, 11 insertions, 7 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index a2db0915..8c7ec6d8 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -983,7 +983,12 @@ let rec convertStmt env s =
Scontinue
| C.Sswitch(e, s1) ->
let (init, cases) = groupSwitch (flattenSwitch s1) in
- if init.sdesc <> C.Sskip then
+ let rec init_debug s =
+ match s.sdesc with
+ | Sseq (a,b) -> init_debug a && init_debug b
+ | C.Sskip -> true
+ | _ -> Cutil.is_debug_stmt s in
+ if init.sdesc <> C.Sskip && not (init_debug init) then
begin
warning "ignored code at beginning of 'switch'";
contains_case init
@@ -1103,16 +1108,16 @@ let rec convertInit env init =
| C.Init_single e ->
Init_single (convertExpr env e)
| C.Init_array il ->
- Init_array (convertInitList env il)
+ Init_array (convertInitList env (List.rev il) Init_nil)
| C.Init_struct(_, flds) ->
- Init_struct (convertInitList env (List.map snd flds))
+ Init_struct (convertInitList env (List.rev_map snd flds) Init_nil)
| C.Init_union(_, fld, i) ->
Init_union (intern_string fld.fld_name, convertInit env i)
-and convertInitList env il =
+and convertInitList env il accu =
match il with
- | [] -> Init_nil
- | i :: il' -> Init_cons(convertInit env i, convertInitList env il')
+ | [] -> accu
+ | i :: il' -> convertInitList env il' (Init_cons(convertInit env i, accu))
let convertInitializer env ty i =
match Initializers.transl_init
@@ -1313,4 +1318,3 @@ let convertProgram p =
if Cerrors.check_errors () then None else Some p'
with Env.Error msg ->
error (Env.error_message msg); None
-