aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2019-05-20 19:33:52 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2019-05-20 19:33:52 +0200
commit45f7c8be7179942d9667a5a26cb1bb6f6fcd2d04 (patch)
tree0c20137a3f67ca4fa626dbf71b13741a18289fb8
parentdf24f45af3e156670a39b553ebbcaba7403f0af3 (diff)
downloadcompcert-45f7c8be7179942d9667a5a26cb1bb6f6fcd2d04.tar.gz
compcert-45f7c8be7179942d9667a5a26cb1bb6f6fcd2d04.zip
Add a check for the args of unprototyped calls.
The arguments that are passed to an unprototyped function must also be checked to be valid types passed to a function, i.e. they must be complete types after argument conversion.
-rw-r--r--cparser/Elab.ml11
1 files changed, 8 insertions, 3 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index f79750c2..13aab900 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1815,7 +1815,7 @@ let elab_expr ctx loc env a =
emit_elab ~linkage env loc (Gdecl(sto, id, ty, None));
{ edesc = EVar id; etyp = ty },env
| _ -> elab env a1 in
- let bl = mmap elab env al in
+ let (bl, env) = mmap elab env al in
(* Extract type information *)
let (res, args, vararg) =
match unroll env b1.etyp with
@@ -1830,8 +1830,13 @@ let elab_expr ctx loc env a =
(* Type-check the arguments against the prototype *)
let bl',env =
match args with
- | None -> bl
- | Some proto -> elab_arguments 1 bl proto vararg in
+ | None ->
+ List.iter (fun arg ->
+ let arg_typ = argument_conversion env arg.etyp in
+ if incomplete_type env arg_typ then
+ error "argument type %a is incomplete" (print_typ env) arg.etyp;
+ ) bl; (bl,env)
+ | Some proto -> elab_arguments 1 (bl, env) proto vararg in
{ edesc = ECall(b1, bl'); etyp = res },env
| UNARY(POSINCR, a1) ->