From 6ceceaed3d71a785fa1cccc1059c9a141e99eee1 Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 22 Aug 2011 08:25:44 +0000 Subject: arm/PrintAsm: don't generate "vfd" directive, useless? cparser: distinguish more carefully between lvalues and modifiable lvalues. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1722 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/Cutil.ml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'cparser/Cutil.ml') diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 103dda4..448f488 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -632,17 +632,26 @@ let type_of_constant = function (* Check that a C expression is a lvalue *) -let rec is_lvalue env e = - (* Type must not be array or function *) - match unroll env e.etyp with - | TFun _ | TArray _ -> false - | _ -> - match e.edesc with - | EVar id -> true - | EUnop((Oderef | Oarrow _), _) -> true - | EUnop(Odot _, e') -> is_lvalue env e' - | EBinop(Oindex, _, _, _) -> true - | _ -> false +let rec is_lvalue e = + match e.edesc with + | EVar id -> true + | EUnop((Oderef | Oarrow _), _) -> true + | EUnop(Odot _, e') -> is_lvalue e' + | EBinop(Oindex, _, _, _) -> true + | _ -> false + +(* Check that a C expression is a modifiable l-value: an l-value + whose type is not const, neither an array type, nor a function type, + nor an incomplete type. *) + +let is_modifiable_lvalue env e = + is_lvalue e + && not (List.mem AConst (attributes_of_type env e.etyp)) + && not (incomplete_type env e.etyp) + && begin match unroll env e.etyp with + | TFun _ | TArray _ -> false + | _ -> true + end (* Check that a C expression is the literal "0", which can be used as a pointer. *) -- cgit v1.2.3