aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-08-29 12:56:41 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-08-29 12:56:41 +0200
commit64a1e734dfe24194bafd33cff1fbe4d9e1cfdf14 (patch)
tree1aed20bb3e321eedf3c473de4242fc230fdc30b6
parent5daf835c454c31dcf29b8b9832d9050cf5822516 (diff)
downloadcompcert-64a1e734dfe24194bafd33cff1fbe4d9e1cfdf14.tar.gz
compcert-64a1e734dfe24194bafd33cff1fbe4d9e1cfdf14.zip
Pass the environment of k&r param elaboration.
The environment where the types are inserted is passed back to allow introducing structs in k&r parameters. Bug 19668
-rw-r--r--cparser/Elab.ml18
1 files changed, 10 insertions, 8 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index a5032292..aea4f2be 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -2028,8 +2028,9 @@ let elab_KR_function_parameters env params defs loc =
| d -> (* Should never be produced by the parser *)
fatal_error (get_definitionloc d)
"Illegal declaration of function parameter" in
- let kr_params_defs =
- List.concat (fst (mmap elab_param_def env defs)) in
+ let kr_params_defs,paramsenv =
+ let params,paramsenv = mmap elab_param_def env defs in
+ List.concat params,paramsenv in
(* Find the type of a parameter *)
let type_of_param param =
match List.filter (fun (p, _) -> p = param) kr_params_defs with
@@ -2066,7 +2067,8 @@ let elab_KR_function_parameters env params defs loc =
ps
end
in
- match_params [] [] params
+ let a,b = match_params [] [] params in
+ a,b,paramsenv
(* Look for varargs flag in previous definitions of a function *)
@@ -2100,17 +2102,17 @@ let elab_fundef env spec name defs body loc =
- [ty]: the full, prototyped type of the function
- [extra_decls]: extra declarations to be inserted at the
beginning of the function *)
- let (ty, extra_decls) =
+ let (ty, extra_decls,env1) =
match ty, kr_params with
| TFun(ty_ret, None, vararg, attr), None ->
- (TFun(ty_ret, Some [], vararg, attr), [])
+ (TFun(ty_ret, Some [], vararg, attr), [],env1)
| ty, None ->
- (ty, [])
+ (ty, [],env1)
| TFun(ty_ret, None, false, attr), Some params ->
warning loc "Non-prototype, pre-standard function definition.@ Converting to prototype form";
- let (params', extra_decls) =
+ let (params', extra_decls,env) =
elab_KR_function_parameters env params defs loc in
- (TFun(ty_ret, Some params', inherit_vararg env s sto ty, attr), extra_decls)
+ (TFun(ty_ret, Some params', inherit_vararg env s sto ty, attr), extra_decls,env)
| _, Some params ->
assert false
in