diff options
| author | Alasdair Armstrong | 2018-09-13 17:38:09 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-09-13 17:38:09 +0100 |
| commit | 03387349dceaecd8feb708eb467a0bde372cb664 (patch) | |
| tree | 7fa4134a58d5d76fe345a680eed1bd9e6a079352 /src/rewrites.ml | |
| parent | 61abeccf6c37169bc22a1674897caf482195857f (diff) | |
C: Fix an issue with assigning to unitialized variables at end of blocks
Assigning to an uninitialized variable as the last statement in a
block is almost certainly a type, and if that occurs then the
lift_assign re-write will introduce empty blocks causing this error to
occur. Now when we see such an empty block when converting to A-normal
form we turn it into unit, and emit a warning stating that an empty
block has been found as well as the probable cause (uninitialized
variable).
Diffstat (limited to 'src/rewrites.ml')
| -rw-r--r-- | src/rewrites.ml | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rewrites.ml b/src/rewrites.ml index f02943a5..eafbd6a8 100644 --- a/src/rewrites.ml +++ b/src/rewrites.ml @@ -1763,7 +1763,7 @@ let rewrite_exp_lift_assign_intro rewriters ((E_aux (exp,((l,_) as annot))) as f let e' = re' (rewrite_base e) in let exps' = walker exps in let effects = union_eff_exps exps' in - let block = E_aux (E_block exps', (l, mk_tannot env unit_typ effects)) in + let block = E_aux (E_block exps', (gen_loc l, mk_tannot env unit_typ effects)) in [fix_eff_exp (E_aux (E_var(le', e', block), annot))] (*| ((E_aux(E_if(c,t,e),(l,annot))) as exp)::exps -> let vars_t = introduced_variables t in @@ -1815,7 +1815,7 @@ let rewrite_exp_lift_assign_intro rewriters ((E_aux (exp,((l,_) as annot))) as f when lexp_is_local_intro le (env_of full_exp) && not (lexp_is_effectful le) -> let (le', re') = rewrite_lexp_to_rhs le in let e' = re' (rewrite_base e) in - let block = annot_exp (E_block []) l (env_of full_exp) unit_typ in + let block = annot_exp (E_block []) (gen_loc l) (env_of full_exp) unit_typ in check_exp (env_of full_exp) (strip_exp (E_aux (E_var(le', e', block), annot))) (typ_of full_exp) | _ -> rewrite_base full_exp |
