Commit d119bf79 by Richard Sandiford Committed by Richard Sandiford

Fix -Wreturn-type for static naked functions in C

This patch extends the fix for PR53633 to include static functions,
which were giving a bogus -Wreturn-type warning for C but not for C++.

2019-07-18  Richard Sandiford  <richard.sandiford@arm.com>

gcc/c/
	PR c/53633
	* c-decl.c (finish_function): Check targetm.warn_func_return
	before issuing a -Wreturn-type warning.

gcc/testsuite/
	* c-c++-common/pr53633-2.c: New test.

From-SVN: r273568
parent d1f2e4c1
2019-07-18 Richard Sandiford <richard.sandiford@arm.com>
PR c/53633
* c-decl.c (finish_function): Check targetm.warn_func_return
before issuing a -Wreturn-type warning.
2019-07-12 Alexandre Oliva <oliva@adacore.com> 2019-07-12 Alexandre Oliva <oliva@adacore.com>
* gimple-parser.c (c_parser_gimple_try_stmt): New. * gimple-parser.c (c_parser_gimple_try_stmt): New.
......
...@@ -9687,6 +9687,7 @@ finish_function (void) ...@@ -9687,6 +9687,7 @@ finish_function (void)
/* Normally, with -Wreturn-type, flow will complain, but we might /* Normally, with -Wreturn-type, flow will complain, but we might
optimize out static functions. */ optimize out static functions. */
&& !TREE_PUBLIC (fndecl) && !TREE_PUBLIC (fndecl)
&& targetm.warn_func_return (fndecl)
&& warning (OPT_Wreturn_type, && warning (OPT_Wreturn_type,
"no return statement in function returning non-void")) "no return statement in function returning non-void"))
TREE_NO_WARNING (fndecl) = 1; TREE_NO_WARNING (fndecl) = 1;
......
2019-07-18 Richard Sandiford <richard.sandiford@arm.com>
* c-c++-common/pr53633-2.c: New test.
2019-07-17 Alexandre Oliva <oliva@adacore.com> 2019-07-17 Alexandre Oliva <oliva@adacore.com>
PR middle-end/81824 PR middle-end/81824
......
/* { dg-do compile } */
/* { dg-require-effective-target naked_functions } */
/* { dg-options "-O2 -Wall" } */
/* Check that we do not get warnings about missing return statements
or bogus looking noreturn functions. */
static int __attribute__((naked))
foo (void)
{
__asm__ ("");
}
static int __attribute__((naked,noreturn))
bar (void)
{
__asm__ ("");
}
int foo_caller (void) { return foo (); }
int bar_caller (void) { return bar (); }
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