aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-07-14 15:38:15 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-07-14 15:38:15 +0200
commitc51f48cc760389a67a729b7b977502eb21c33e50 (patch)
treef11bceba90bb3747ceed236433de28933642f00e /cparser
parentf995a671ceb28c2a83e5e5574c3cdb46fd5e0f57 (diff)
downloadcompcert-c51f48cc760389a67a729b7b977502eb21c33e50.tar.gz
compcert-c51f48cc760389a67a729b7b977502eb21c33e50.zip
Reject incomplete types as return type.
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Elab.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 9ff7823f..de24871f 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1884,7 +1884,10 @@ let elab_fundef env spec name body loc =
(* Extract info from type *)
let (ty_ret, params, vararg, attr) =
match ty with
- | TFun(ty_ret, Some params, vararg, attr) -> (ty_ret, params, vararg, attr)
+ | TFun(ty_ret, Some params, vararg, attr) ->
+ if wrap incomplete_type loc env1 ty_ret && not (is_void_type env ty_ret) then
+ fatal_error loc "return type is an incomplete type";
+ (ty_ret, params, vararg, attr)
| _ -> fatal_error loc "wrong type for function definition" in
(* Enter function in the environment, for recursive references *)
let (fun_id, sto1, env1,ty) = enter_or_refine_ident false loc env1 s sto ty in