aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-08-20 11:09:33 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-08-20 11:09:33 +0200
commit939977c7142222d0ec0b67322b06daa187a7b829 (patch)
tree78fa95dbe10be83c51df063999695f7ea62e681d /cparser/Elab.ml
parentb9a6a50546222269bb9445d0d21d948028b2720a (diff)
downloadcompcert-kvx-939977c7142222d0ec0b67322b06daa187a7b829.tar.gz
compcert-kvx-939977c7142222d0ec0b67322b06daa187a7b829.zip
Added warning for incomplete tentative static defs (#114)
Tentative static definitions with incomplete type are not allowed in C99. However most popular compilers support them and warn about them. Bug 23377
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml9
1 files changed, 5 insertions, 4 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 46861708..cc7648e0 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -2354,10 +2354,11 @@ let enter_decdefs local nonstatic_inline loc env sto dl =
(* update environment with refined type *)
let env2 = Env.add_ident env1 id sto' ty' in
(* check for incomplete type *)
- if local && sto' <> Storage_extern
- && not isfun
- && wrap incomplete_type loc env ty' then
- error loc "variable has incomplete type %a" (print_typ env) ty';
+ if not isfun && wrap incomplete_type loc env ty' then
+ if not local && sto' = Storage_static then begin
+ warning loc Tentative_incomplete_static "tentative static definition with incomplete type";
+ end else if local && sto' <> Storage_extern then
+ error loc "variable has incomplete type %a" (print_typ env) ty';
(* check for static variables in nonstatic inline functions *)
if local && nonstatic_inline
&& sto' = Storage_static