re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)

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
parent 05ce2012
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> 2006-05-20 Uros Bizjak <ubizjak@gmail.com>
PR target/31585 PR target/31585
......
...@@ -6788,13 +6788,6 @@ finish_function (void) ...@@ -6788,13 +6788,6 @@ finish_function (void)
TREE_NO_WARNING (fndecl) = 1; 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 /* Store the end of the function, so that we get good line number
info for the epilogue. */ info for the epilogue. */
cfun->function_end_locus = input_location; cfun->function_end_locus = input_location;
......
...@@ -2807,9 +2807,13 @@ This warning is enabled by @option{-Wall} for C and C++. ...@@ -2807,9 +2807,13 @@ This warning is enabled by @option{-Wall} for C and C++.
@item -Wreturn-type @item -Wreturn-type
@opindex Wreturn-type @opindex Wreturn-type
Warn whenever a function is defined with a return-type that defaults to @opindex Wno-return-type
@code{int}. Also warn about any @code{return} statement with no Warn whenever a function is defined with a return-type that defaults
return-value in a function whose return-type is not @code{void}. 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 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, such as @code{const}. For ISO C such a type qualifier has no effect,
...@@ -3130,22 +3134,6 @@ messages for these events: ...@@ -3130,22 +3134,6 @@ messages for these events:
@itemize @bullet @itemize @bullet
@item @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{>=}. An unsigned value is compared against zero with @samp{<} or @samp{>=}.
@item @r{(C only)} @item @r{(C only)}
......
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> 2006-05-20 Uros Bizjak <ubizjak@gmail.com>
PR target/31585 PR target/31585
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2003 Free Software Foundation Inc. */ Copyright (C) 2003 Free Software Foundation Inc. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O -finline-functions -Wextra" } */ /* { dg-options "-O -finline-functions -Wreturn-type" } */
extern int i; extern int i;
extern int foo (void); extern int foo (void);
...@@ -12,10 +12,10 @@ int foo (void) ...@@ -12,10 +12,10 @@ int foo (void)
{ {
if( i ) return 0; if( i ) return 0;
else return 1; else return 1;
} /* { dg-bogus "may return with or without a value" } */ }
int bar (void) int bar (void)
{ {
if( i ) return; if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */
else return 1; else return 1;
} /* { dg-warning "may return with or without a value" } */ }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2003 Free Software Foundation Inc. */ Copyright (C) 2003 Free Software Foundation Inc. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O -finline-functions -Wextra" } */ /* { dg-options "-O -finline-functions -Wreturn-type" } */
extern int i; extern int i;
extern int foo (void); extern int foo (void);
...@@ -10,9 +10,9 @@ extern int bar (void); ...@@ -10,9 +10,9 @@ extern int bar (void);
int foo (void) int foo (void)
{ {
if( i ) return; if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */
else return 1; else return 1;
} /* { dg-warning "may return with or without a value" } */ }
int bar (void) int bar (void)
{ {
......
/* Test for spurious "may or may not return a value" warnings. */ /* Test for spurious "may or may not return a value" warnings. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wextra" } */ /* { dg-options "-Wreturn-type -Wextra" } */
#include <objc/Object.h> #include <objc/Object.h>
......
/* Test for spurious "may or may not return a value" warnings. */ /* Test for spurious "may or may not return a value" warnings. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wextra" } */ /* { dg-options "-Wreturn-type -Wextra" } */
#include <objc/Object.h> #include <objc/Object.h>
...@@ -16,11 +16,11 @@ extern int bar; ...@@ -16,11 +16,11 @@ extern int bar;
- (id) meth1 { - (id) meth1 {
if (bar) if (bar)
return [Object new]; return [Object new];
return; return; /* { dg-warning "'return' with no value, in function returning non-void" } */
} /* { dg-warning "this function may return with or without a value" } */ }
- (void) meth2 { - (void) meth2 {
if (!bar) if (!bar)
return; return;
bar = 0; 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 @end
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