Commit 0cd020ae by Prathamesh Kulkarni Committed by Prathamesh Kulkarni

c-decl.c (start_decl): Do not warn if variables is named as main and is a local variable.

2018-08-15  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

c/
	* c-decl.c (start_decl): Do not warn if variables is named as main
	and is a local variable.

testsuite/
	* gcc.dg/wmain.c: New test.

From-SVN: r263562
parent bcee52c4
2018-08-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* c-decl.c (start_decl): Do not warn if variables is named as main
and is a local variable.
2018-08-15 Iain Sandoe <iain@sandoe.co.uk> 2018-08-15 Iain Sandoe <iain@sandoe.co.uk>
PR c/19315 PR c/19315
......
...@@ -4700,7 +4700,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4700,7 +4700,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
if (expr) if (expr)
add_stmt (fold_convert (void_type_node, expr)); add_stmt (fold_convert (void_type_node, expr));
if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))) if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))
&& TREE_PUBLIC (decl))
warning (OPT_Wmain, "%q+D is usually a function", decl); warning (OPT_Wmain, "%q+D is usually a function", decl);
if (initialized) if (initialized)
......
2018-08-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* gcc.dg/wmain.c: New test.
2018-08-15 Iain Sandoe <iain@sandoe.co.uk> 2018-08-15 Iain Sandoe <iain@sandoe.co.uk>
PR c/19315 PR c/19315
......
/* { dg-do compile } */
/* { dg-options "-Wall" } */
int main; /* { dg-warning "'main' is usually a function" } */
int foo()
{
int main = 1; /* { dg-bogus "'main' is usually a function" } */
return main;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment