diff options
author | Bernhard Schommer <bschommer@users.noreply.github.com> | 2018-08-17 13:57:00 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2018-08-17 13:57:00 +0200 |
commit | 44c859e5ffd95498b6e0dc504a9fc54cef86aae8 (patch) | |
tree | 066e0f63c2b210b72413ade8850d51777363e99e | |
parent | e108b274eda3739ff0d69efff626bb1c1dbcaed1 (diff) | |
download | compcert-44c859e5ffd95498b6e0dc504a9fc54cef86aae8.tar.gz compcert-44c859e5ffd95498b6e0dc504a9fc54cef86aae8.zip |
Earlier check for invalid asm outputs. (#130)
Since a non modifiable lvalue is an invalid asm output it should
be checked earlier, otherwise this leads to a retyping error
later.
Bug 24285
-rw-r--r-- | cparser/Elab.ml | 5 | ||||
-rw-r--r-- | cparser/ExtendedAsm.ml | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml index d0de1058..cff9ed5b 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -2879,6 +2879,11 @@ let rec elab_stmt env ctx s = let a = elab_cvspecs env cv_specs in let s = elab_simple_string loc wide chars in let outputs,env = mmap (elab_asm_operand ctx loc) env outputs in + List.iter + (fun (lbl, cst, e) -> + if not (is_modifiable_lvalue env e) then + error loc "asm output is not a modifiable l-value";) + outputs; let inputs ,env= mmap (elab_asm_operand ctx loc) env inputs in let flags = List.map (fun (w,c) -> elab_simple_string loc w c) flags in { sdesc = Sasm(a, s, outputs, inputs, flags); diff --git a/cparser/ExtendedAsm.ml b/cparser/ExtendedAsm.ml index 6cd95aec..8b694ac4 100644 --- a/cparser/ExtendedAsm.ml +++ b/cparser/ExtendedAsm.ml @@ -126,8 +126,6 @@ let transf_outputs loc env = function | [] -> (None, [], StringMap.empty, 0, 0) | [(lbl, cstr, e)] -> - if not (is_modifiable_lvalue env e) then - error loc "asm output is not a modifiable l-value"; let valid = Str.string_match re_valid_output cstr 0 in if valid && String.contains cstr 'r' then if is_reg_pair env e.etyp then |