summaryrefslogtreecommitdiff
path: root/cfrontend
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-03-25 13:20:59 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-03-25 13:20:59 +0000
commit3f6b5aee7b85cb588093dfe571e2e1606f80235a (patch)
treeeced123db9f6c7f71acce82fc112a7470fafca7e /cfrontend
parent86ad62294dee024deb41c0f522973a0770ffa45a (diff)
Error when calling un-prototyped function.
Removed warning "un-prototyped function type", fires too often. The important thing is to mark errors when declaring and calling unproto fns. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2160 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend')
-rw-r--r--cfrontend/C2C.ml14
1 files changed, 8 insertions, 6 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index 44d07e6..3bf459f 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -287,7 +287,7 @@ let convertTyp env t =
if Cutil.is_composite_type env tres then
unsupported "return type is a struct or union";
Tfunction(begin match targs with
- | None -> warning "un-prototyped function type"; Tnil
+ | None -> (*warning "un-prototyped function type";*) Tnil
| Some tl -> convertParams seen tl
end,
convertTyp seen tres)
@@ -349,7 +349,7 @@ let cacheCompositeDef env su id attr flds =
let rec projFunType env ty =
match Cutil.unroll env ty with
- | TFun(res, args, vararg, attr) -> Some(res, vararg)
+ | TFun(res, args, vararg, attr) -> Some(res, args, vararg)
| TPtr(ty', attr) -> projFunType env ty'
| _ -> None
@@ -574,10 +574,12 @@ let rec convertExpr env e =
match projFunType env fn.etyp with
| None ->
error "wrong type for function part of a call"; ezero
- | Some(res, false) ->
+ | Some(tres, targs, false) ->
(* Non-variadic function *)
+ if targs = None then
+ unsupported "call to non-prototyped function";
Ecall(convertExpr env fn, convertExprList env args, ty)
- | Some(res, true) ->
+ | Some(tres, targs, true) ->
(* Variadic function: generate a call to a stub function with
the appropriate number and types of arguments. Works only if
the function expression e is a global variable. *)
@@ -590,7 +592,7 @@ let rec convertExpr env e =
unsupported "call to variadic function";
"<error>" in
let targs = convertTypList env (List.map (fun e -> e.etyp) args) in
- let tres = convertTyp env res in
+ let tres = convertTyp env tres in
let (stub_fun_name, stub_fun_typ) =
register_stub_function fun_name tres targs in
Ecall(Evalof(Evar(intern_string stub_fun_name, stub_fun_typ),
@@ -872,7 +874,7 @@ let rec convertGlobdecls env res gl =
| TFun(_, Some _, false, _) ->
convertGlobdecls env (convertFundecl env d :: res) gl'
| TFun(_, None, false, _) ->
- error ("'" ^ id.name ^ "' is declared without a function prototype");
+ unsupported ("'" ^ id.name ^ "' is declared without a function prototype");
convertGlobdecls env res gl'
| TFun(_, _, true, _) ->
convertGlobdecls env res gl'