From 6c295e28af6a7facd10bd8672a8857a6b1b4971c Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 23 Mar 2018 11:30:27 +0100 Subject: Do not allow inline on main and warn for Noreturn (#63) * Do not allow inline on main(). The C99 standard says that in a hosted environment inline shall not appear in a declaration of main. Bug 23274 * Added warning for _Noreturn on main(). The C11 standard does not allow any function specifier on the main function. Bug 23274 --- cparser/Elab.ml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cparser/Elab.ml') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 4de43fe0..97ee4f76 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -2334,6 +2334,10 @@ let elab_fundef env spec name defs body loc = (* Special treatment of the "main" function. *) let body2 = if s = "main" then begin + if inline then + error loc "'main' is not allowed to be declared inline"; + if noret then + warning loc Unnamed "'main' is not allowed to be declared _Noreturn"; match unroll env ty_ret with | TInt(IInt, []) -> (* Add implicit "return 0;" at end of function body. -- cgit