From 939977c7142222d0ec0b67322b06daa187a7b829 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 20 Aug 2018 11:09:33 +0200 Subject: 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 --- cparser/Elab.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cparser/Elab.ml') 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 -- cgit