aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-08-22 16:54:41 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-08-22 16:54:41 +0200
commitc9afca3d377bd32bd8dd551aee49d561cc1fa770 (patch)
tree8baf40d368afff47720e33d761e96d301a145e86 /cparser
parent97ef3561168a6262833e65aba379ab9aca1a1a17 (diff)
downloadcompcert-c9afca3d377bd32bd8dd551aee49d561cc1fa770.tar.gz
compcert-c9afca3d377bd32bd8dd551aee49d561cc1fa770.zip
Better error message for function initializer
Initializers for function variables are not allowed. CompCert now reports an error and exits. Bug 19606
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Elab.ml4
1 files changed, 4 insertions, 0 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 99370df6..76a7379c 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1288,6 +1288,10 @@ and elab_single zi a il =
(* Start with top-level object initialized to default *)
in
+if is_function_type env ty_root then begin
+ error loc "illegal initializer (only variables can be initialized)";
+ raise Exit
+end;
if wrap incomplete_type loc env ty_root then begin
error loc "variable has incomplete type %a" Cprint.typ ty_root;
raise Exit