aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2017-12-12 14:18:46 +0100
committerGitHub <noreply@github.com>2017-12-12 14:18:46 +0100
commit6753e8f33cd4b26dbb256ae4886f11d60eb0e370 (patch)
treedf71751d2915ba41e6005c10e6d78b3a51bb4bf9 /cparser
parent1057d06826cde79a65dd542c1b4dd72e0c25243d (diff)
downloadcompcert-6753e8f33cd4b26dbb256ae4886f11d60eb0e370.tar.gz
compcert-6753e8f33cd4b26dbb256ae4886f11d60eb0e370.zip
Do not pass the env back from for stmt decls. (#42)
* Do not pass the env back from for stmt decls. This is the source of issue #211, the environment from the elaboration of the declaration and expressions in the for loop should not be passed back.
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Elab.ml14
1 files changed, 7 insertions, 7 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index e846e301..86e71865 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -2529,7 +2529,7 @@ let rec elab_stmt env ctx s =
{ sdesc = Sdowhile(s1', a'); sloc = elab_loc loc },env
| FOR(fc, a2, a3, s1, loc) ->
- let (a1', env', decls') =
+ let (a1', env_decls, decls') =
match fc with
| Some (FC_EXP a1) ->
let a1,env = elab_for_expr ctx.ctx_vararg loc env (Some a1) in
@@ -2542,15 +2542,15 @@ let rec elab_stmt env ctx s =
let loc = elab_loc (Cabshelper.get_definitionloc def) in
(sskip, env',
Some(List.map (fun d -> {sdesc = Sdecl d; sloc = loc}) dcl)) in
- let a2',env =
+ let a2',env_test =
match a2 with
- | None -> intconst 1L IInt,env
- | Some a2 -> elab_expr ctx.ctx_vararg loc env' a2
+ | None -> intconst 1L IInt,env_decls
+ | Some a2 -> elab_expr ctx.ctx_vararg loc env_decls a2
in
- if not (is_scalar_type env' a2'.etyp) then
+ if not (is_scalar_type env_test a2'.etyp) then
error loc "controlling expression of 'for' does not have scalar type (%a invalid)" (print_typ env) a2'.etyp;
- let a3',env' = elab_for_expr ctx.ctx_vararg loc env' a3 in
- let s1',env' = elab_stmt env' (ctx_loop ctx) s1 in
+ let a3',env_for = elab_for_expr ctx.ctx_vararg loc env_test a3 in
+ let s1',env_body = elab_stmt env_for (ctx_loop ctx) s1 in
let sfor = { sdesc = Sfor(a1', a2', a3', s1'); sloc = elab_loc loc } in
begin match decls' with
| None -> sfor,env