Skip to content
Snippets Groups Projects
Commit d0ed98b8 authored by xleroy's avatar xleroy
Browse files

Unsupported: return/return type mismatches

git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1180 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
parent 01f1bf7a
No related branches found
No related tags found
No related merge requests found
......@@ -378,6 +378,14 @@ let cache_address ty e (f: expr -> statement) =
f (Expr(Ederef(Expr(Evar t, typ)), ty)))
end
let current_function_return_type() =
match !current_function with
| None -> assert false
| Some f ->
match f.svar.vtype with
| TFun(ty_ret, ty_args, _, _) -> ty_ret
| _ -> assert false
(** Detect and report GCC's __builtin_ functions *)
let check_builtin s =
......@@ -915,9 +923,16 @@ and convertStmtKind = function
processInstrList iList
| Return (eOpt, loc) ->
updateLoc(loc);
let ty_ret = current_function_return_type() in
let eOpt' = match eOpt with
| None -> None
| Some e -> Some (convertExp e)
| None ->
if isVoidType ty_ret
then None
else unsupported ("`return' without a value in function with non-void return type")
| Some e ->
if isVoidType ty_ret
then unsupported ("`return' with a value in function returning void")
else Some (convertExp e)
in
Sreturn eOpt'
| Goto (sref, loc) ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment