diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2011-07-16 16:17:08 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2011-07-16 16:17:08 +0000 |
commit | a335e621aaa85a7f73b16c121261dbecf8e68340 (patch) | |
tree | 31312a22aafc7f66818c0c82f4c96e88ff391595 /cparser | |
parent | 93b89122000e42ac57abc39734fdf05d3a89e83c (diff) |
In conditional expressions e1 ? e2 : e3, cast the results of e2 and e3 to the type of the whole conditional expression.
Replaced predicates "cast", "is_true" and "is_false" by functions "sem_cast" and "bool_val".
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1684 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cparser')
-rw-r--r-- | cparser/Ceval.ml | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cparser/Ceval.ml b/cparser/Ceval.ml index 87b50e0..fbeb522 100644 --- a/cparser/Ceval.ml +++ b/cparser/Ceval.ml @@ -253,7 +253,9 @@ let rec expr env e = | EBinop(op, e1, e2, ty) -> binop env op ty e.etyp e1.etyp (expr env e1) e2.etyp (expr env e2) | EConditional(e1, e2, e3) -> - if boolean_value (expr env e1) then expr env e2 else expr env e3 + if boolean_value (expr env e1) + then cast env e.etyp e2.etyp (expr env e2) + else cast env e.etyp e3.etyp (expr env e3) | ECast(ty, e1) -> cast env ty e1.etyp (expr env e1) | ECall _ -> |