re PR middle-end/42674 (Bogus "no return statement in function returning non-void...
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Jan 2010 22:43:56 +0000 (23:43 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Jan 2010 22:43:56 +0000 (23:43 +0100)
PR middle-end/42674
* c-decl.c (finish_function): Don't emit -Wreturn-type warnings in
functions with noreturn attribute.

* decl.c (finish_function): Don't emit -Wreturn-type warnings in
functions with noreturn attribute.

* c-c++-common/pr42674.c: New test.

From-SVN: r155920

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr42674.c [new file with mode: 0644]

index 29f71b12d14678e818a0e5258888b529f4af0917..ce96cca5aca5d8e705bb087c681a6f36a39c7de3 100644 (file)
@@ -1,5 +1,9 @@
 2010-01-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/42674
+       * c-decl.c (finish_function): Don't emit -Wreturn-type warnings in
+       functions with noreturn attribute.
+
        PR c++/42608
        * varasm.c (declare_weak): Add weak attribute to decl if it
        doesn't have one already.
index a244a83e7878eb8be72b50f0029938214c8c7da4..91d58844550867535688eae690a18001d8fb6497 100644 (file)
@@ -8032,6 +8032,8 @@ finish_function (void)
       && !current_function_returns_value && !current_function_returns_null
       /* Don't complain if we are no-return.  */
       && !current_function_returns_abnormally
+      /* Don't complain if we are declared noreturn.  */
+      && !TREE_THIS_VOLATILE (fndecl)
       /* Don't warn for main().  */
       && !MAIN_NAME_P (DECL_NAME (fndecl))
       /* Or if they didn't actually specify a return type.  */
index c6e309f6820619aac4c7016f000bc7f6de9d4bff..1d1326163710f691fd85feee8d81ed537faff9c9 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/42674
+       * decl.c (finish_function): Don't emit -Wreturn-type warnings in
+       functions with noreturn attribute.
+
 2010-01-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/42701
index e89113a24027cbd406adcc861adfdf149cb1f2f7..2409aa31b1525c6c41baccb035c37df9c140bfe4 100644 (file)
@@ -12541,6 +12541,8 @@ finish_function (int flags)
       && !current_function_returns_value && !current_function_returns_null
       /* Don't complain if we abort or throw.  */
       && !current_function_returns_abnormally
+      /* Don't complain if we are declared noreturn.  */
+      && !TREE_THIS_VOLATILE (fndecl)
       && !DECL_NAME (DECL_RESULT (fndecl))
       && !TREE_NO_WARNING (fndecl)
       /* Structor return values (if any) are set by the compiler.  */
index 5b284490686b2f1a25638e96b5558d294fc45f47..f4d13bedd86a16b5a25eb32e83c713287e49e647 100644 (file)
@@ -1,5 +1,8 @@
 2010-01-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/42674
+       * c-c++-common/pr42674.c: New test.
+
        PR c++/42608
        * g++.dg/template/instantiate11.C: New test.
 
diff --git a/gcc/testsuite/c-c++-common/pr42674.c b/gcc/testsuite/c-c++-common/pr42674.c
new file mode 100644 (file)
index 0000000..ae6730c
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/42674 */
+/* { dg-do compile } */
+/* { dg-options "-Wreturn-type" } */
+
+extern void bar (void);
+static int foo (void) __attribute__ ((__noreturn__, __used__));
+
+static int
+foo (void)
+{
+  while (1)
+    bar ();
+}