re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 20 May 2007 00:45:58 +0000 (00:45 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 20 May 2007 00:45:58 +0000 (00:45 +0000)
2006-05-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

PR middle-end/7651
* doc/invoke.texi (Wreturn-type): Complete description.
(Wextra): Delete item about return-type warning.
* c-decl.c: Delete redundant Wextra warning.

testsuite/
* gcc.dg/20030906-1.c: Replace Wextra with Wreturn-type.
* gcc.dg/20030906-2.c: Likewise.
* objc.dg/method-17.m: Add -Wreturn-type.
* obj-c++.dg/method-21.mm: Likewise.

From-SVN: r124866

gcc/ChangeLog
gcc/c-decl.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20030906-1.c
gcc/testsuite/gcc.dg/20030906-2.c
gcc/testsuite/obj-c++.dg/method-21.mm
gcc/testsuite/objc.dg/method-17.m

index 01a9a6373622217c3ef05cc48740a706dd68d56e..d92211944a283381918727b083f73af95be567cb 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR middle-end/7651
+       * doc/invoke.texi (Wreturn-type): Complete description.
+       (Wextra): Delete item about return-type warning.
+       * c-decl.c: Delete redundant Wextra warning.
+       
 2006-05-20  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/31585
index db8412cc010feb97a205b94fc4b32959151ec631..1f8943f05a7bb8023d2fe554b1199a8fdf20c965 100644 (file)
@@ -6788,13 +6788,6 @@ finish_function (void)
       TREE_NO_WARNING (fndecl) = 1;
     }
 
-  /* With just -Wextra, complain only if function returns both with
-     and without a value.  */
-  if (extra_warnings
-      && current_function_returns_value
-      && current_function_returns_null)
-    warning (OPT_Wextra, "this function may return with or without a value");
-
   /* Store the end of the function, so that we get good line number
      info for the epilogue.  */
   cfun->function_end_locus = input_location;
index 7aef897f0f5255ff20871ba902379b5a8fe6ebda..7be81671b1339c43b8c1f394ca2161442e4b881a 100644 (file)
@@ -2807,9 +2807,13 @@ This warning is enabled by @option{-Wall} for C and C++.
 
 @item -Wreturn-type
 @opindex Wreturn-type
-Warn whenever a function is defined with a return-type that defaults to
-@code{int}.  Also warn about any @code{return} statement with no
-return-value in a function whose return-type is not @code{void}.
+@opindex Wno-return-type
+Warn whenever a function is defined with a return-type that defaults
+to @code{int}.  Also warn about any @code{return} statement with no
+return-value in a function whose return-type is not @code{void}
+(falling off the end of the function body is considered returning
+without a value), and about a @code{return} statement with a
+expression in a function whose return-type is @code{void}.
 
 Also warn if the return type of a function has a type qualifier
 such as @code{const}.  For ISO C such a type qualifier has no effect,
@@ -3129,22 +3133,6 @@ supported, but the newer name is more descriptive.)  Print extra warning
 messages for these events:
 
 @itemize @bullet
-@item
-A function can return either with or without a value.  (Falling
-off the end of the function body is considered returning without
-a value.)  For example, this function would evoke such a
-warning:
-
-@smallexample
-@group
-foo (a)
-@{
-  if (a > 0)
-    return a;
-@}
-@end group
-@end smallexample
-
 @item
 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
 
index 42f0c6934bf6da0d0dcf7f50a4f7b3ce0cd3f6f7..20d58c7818efef5976524231c855fb0bcd16c124 100644 (file)
@@ -1,3 +1,11 @@
+2006-05-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR middle-end/7651
+       * gcc.dg/20030906-1.c: Replace Wextra with Wreturn-type.
+       * gcc.dg/20030906-2.c: Likewise.
+       * objc.dg/method-17.m: Add -Wreturn-type.
+       * obj-c++.dg/method-21.mm: Likewise.
+       
 2006-05-20  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/31585
index 57d80f044c357555cdff5858e5cadb674c953c26..c416f55ee75bbcde27f58295ae069b4ef0a94e9b 100644 (file)
@@ -2,7 +2,7 @@
    Copyright (C) 2003 Free Software Foundation Inc.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O -finline-functions -Wextra" } */
+/* { dg-options "-O -finline-functions -Wreturn-type" } */
 
 extern int i;
 extern int foo (void);
@@ -12,10 +12,10 @@ int foo (void)
 {
   if( i ) return 0;
   else    return 1;
-}              /* { dg-bogus "may return with or without a value" } */
+}
 
 int bar (void)
 {
-  if( i ) return;
+  if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */
   else    return 1;
-}              /* { dg-warning "may return with or without a value" } */
+}              
index 8f3d3781618e6385f8baedb6e7bd64d1df26309d..1191133e6a06d9563d5e8f7dc2d09134f5725195 100644 (file)
@@ -2,7 +2,7 @@
    Copyright (C) 2003 Free Software Foundation Inc.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O -finline-functions -Wextra" } */
+/* { dg-options "-O -finline-functions -Wreturn-type" } */
 
 extern int i;
 extern int foo (void);
@@ -10,9 +10,9 @@ extern int bar (void);
 
 int foo (void)
 {
-  if( i ) return;
+  if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */
   else    return 1;
-}              /* { dg-warning "may return with or without a value" } */
+}
 
 int bar (void)
 {
index 94291a5a106e43c4f2ee187e1881c3d53f42d768..0c8051c2cc14ea325b0b9a46b9fba69609cd0978 100644 (file)
@@ -1,6 +1,6 @@
 /* Test for spurious "may or may not return a value" warnings.  */
 /* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wreturn-type -Wextra" } */
 
 #include <objc/Object.h>
 
index 5e28ddc1bb782d1ff39a6b03d6c6139d99a3a008..501c2decf958a08b5c88b822551f7de288e5d302 100644 (file)
@@ -1,7 +1,7 @@
 /* Test for spurious "may or may not return a value" warnings.  */
 
 /* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wreturn-type -Wextra" } */
 
 #include <objc/Object.h>
 
@@ -16,11 +16,11 @@ extern int bar;
 - (id) meth1 {
   if (bar)
     return [Object new];
-  return;
-} /* { dg-warning "this function may return with or without a value" } */
+  return; /* { dg-warning "'return' with no value, in function returning non-void" } */
+} 
 - (void) meth2 {
   if (!bar)
     return;
   bar = 0;
-} /* { dg-bogus "this function may return with or without a value" } */
+} /* { dg-bogus "'return' with no value, in function returning non-void" } */
 @end