[gcc/devel/omp/gcc-9] Fix -Wreturn-type for static naked functions in C
Tobias Burnus
burnus@gcc.gnu.org
Thu Mar 5 14:09:00 GMT 2020
https://gcc.gnu.org/g:56544a47e0a36563ff12cbe3fb21ba9f36414fe6
commit 56544a47e0a36563ff12cbe3fb21ba9f36414fe6
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Sat Jul 20 18:50:20 2019 +0000
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-20 Richard Sandiford <richard.sandiford@arm.com>
gcc/c/
Backport from mainline
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.
gcc/testsuite/
Backport from mainline
2019-07-18 Richard Sandiford <richard.sandiford@arm.com>
* c-c++-common/pr53633-2.c: New test.
From-SVN: r273635
Diff:
---
gcc/c/ChangeLog | 9 +++++++++
gcc/c/c-decl.c | 1 +
gcc/testsuite/ChangeLog | 7 +++++++
gcc/testsuite/c-c++-common/pr53633-2.c | 19 +++++++++++++++++++
4 files changed, 36 insertions(+)
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 65e2f92..0411099 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-20 Richard Sandiford <richard.sandiford@arm.com>
+
+ Backport from mainline
+ 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-05-17 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index c8e7cd0..04e0f4d 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -9685,6 +9685,7 @@ finish_function (void)
/* Normally, with -Wreturn-type, flow will complain, but we might
optimize out static functions. */
&& !TREE_PUBLIC (fndecl)
+ && targetm.warn_func_return (fndecl)
&& warning (OPT_Wreturn_type,
"no return statement in function returning non-void"))
TREE_NO_WARNING (fndecl) = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index de0b52c..e57acad 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-20 Richard Sandiford <richard.sandiford@arm.com>
+
+ Backport from mainline
+ 2019-07-18 Richard Sandiford <richard.sandiford@arm.com>
+
+ * c-c++-common/pr53633-2.c: New test.
+
2019-07-18 Kito Cheng <kito.cheng@sifive.com>
Backport from mainline
diff --git a/gcc/testsuite/c-c++-common/pr53633-2.c b/gcc/testsuite/c-c++-common/pr53633-2.c
new file mode 100644
index 0000000..c26cb10
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr53633-2.c
@@ -0,0 +1,19 @@
+/* { 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 (); }
More information about the Gcc-cvs
mailing list