From 04087cd0369ca9f978942715031c7dbd545ffb0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= <manu@gcc.gnu.org>
Date: Sun, 6 Jun 2010 16:40:18 +0000
Subject: [PATCH] re PR c/20000 (missing warning for noreturn function
 returning non-void)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

2010-06-06  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/20000
        * c-decl.c (grokdeclarator): Delete warning.
testsuite/
        * c-c++-common/pr20000.c: New.

From-SVN: r160346
---
 gcc/ChangeLog                        |  5 +++++
 gcc/c-decl.c                         |  6 ------
 gcc/testsuite/ChangeLog              |  5 +++++
 gcc/testsuite/c-c++-common/pr20000.c | 32 ++++++++++++++++++++++++++++
 4 files changed, 42 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/pr20000.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 561371329c3f..b3ef9444b852 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-06  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+	PR c/20000
+        * c-decl.c (grokdeclarator): Delete warning.
+
 2010-06-06  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* stor-layout.c (self_referential_size): Set UNKNOWN_LOCATION on the
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 2485bf44c107..96ef29998445 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5901,12 +5901,6 @@ grokdeclarator (const struct c_declarator *declarator,
 	  pedwarn (loc, OPT_pedantic,
 		   "ISO C forbids qualified function types");
 
-	/* GNU C interprets a volatile-qualified function type to indicate
-	   that the function does not return.  */
-	if ((type_quals & TYPE_QUAL_VOLATILE)
-	    && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
-	  warning_at (loc, 0, "%<noreturn%> function returns non-void value");
-
 	/* Every function declaration is an external reference
 	   (DECL_EXTERNAL) except for those which are not at file
 	   scope and are explicitly declared "auto".  This is
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4400b9a502a1..bda499ed9ce3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-06  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+	PR c/20000
+        * c-c++-common/pr20000.c: New.
+
 2010-06-05  Fabien Chêne  <fabien@gcc.gnu.org>
 
 	PR c++/44086
diff --git a/gcc/testsuite/c-c++-common/pr20000.c b/gcc/testsuite/c-c++-common/pr20000.c
new file mode 100644
index 000000000000..1fcd17877e8b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr20000.c
@@ -0,0 +1,32 @@
+/* PR c/20000 We only want to warn if the function returns
+   explicitly. We do not care about the return type.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int g(void) __attribute__((noreturn)); 
+int g2(void) __attribute__((noreturn)); /* { dg-bogus ".noreturn. function returns non-void value" } */
+void h(void) __attribute__((noreturn));
+
+
+int g(void) {
+  return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
+} /* { dg-warning "'noreturn' function does return" } */
+
+int g2(void) {
+  h();
+}
+
+typedef int ft(void);
+volatile ft vg;
+volatile ft vg2;
+
+int vg(void); 
+int vg2(void); /* { dg-bogus ".noreturn. function returns non-void value" } */
+
+int vg(void) {
+  return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */
+} /* { dg-warning "'noreturn' function does return" "" { target c } 28  } */
+
+int vg2(void) {
+  h();
+}
-- 
GitLab