diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-05-20 00:45:58 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-05-20 00:45:58 +0000 |
commit | ffd5f2761323eea74743302bfdbff644eceae83b (patch) | |
tree | bbcc1e2ae00d84751fb6d9e0d94ad59c5dd5ae75 /gcc | |
parent | 05ce201275137ae82ced2edc32c43acf9fea37d7 (diff) | |
download | gcc-ffd5f2761323eea74743302bfdbff644eceae83b.zip gcc-ffd5f2761323eea74743302bfdbff644eceae83b.tar.gz gcc-ffd5f2761323eea74743302bfdbff644eceae83b.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-decl.c | 7 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 26 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20030906-1.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20030906-2.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/method-21.mm | 2 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/method-17.m | 8 |
8 files changed, 34 insertions, 38 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 01a9a63..d922119 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index db8412c..1f8943f 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7aef897..7be8167 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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, @@ -3130,22 +3134,6 @@ 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{>=}. @item @r{(C only)} diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 42f0c69..20d58c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gcc.dg/20030906-1.c b/gcc/testsuite/gcc.dg/20030906-1.c index 57d80f0..c416f55 100644 --- a/gcc/testsuite/gcc.dg/20030906-1.c +++ b/gcc/testsuite/gcc.dg/20030906-1.c @@ -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" } */ +} diff --git a/gcc/testsuite/gcc.dg/20030906-2.c b/gcc/testsuite/gcc.dg/20030906-2.c index 8f3d378..1191133 100644 --- a/gcc/testsuite/gcc.dg/20030906-2.c +++ b/gcc/testsuite/gcc.dg/20030906-2.c @@ -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) { diff --git a/gcc/testsuite/obj-c++.dg/method-21.mm b/gcc/testsuite/obj-c++.dg/method-21.mm index 94291a5..0c8051c 100644 --- a/gcc/testsuite/obj-c++.dg/method-21.mm +++ b/gcc/testsuite/obj-c++.dg/method-21.mm @@ -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> diff --git a/gcc/testsuite/objc.dg/method-17.m b/gcc/testsuite/objc.dg/method-17.m index 5e28ddc..501c2de 100644 --- a/gcc/testsuite/objc.dg/method-17.m +++ b/gcc/testsuite/objc.dg/method-17.m @@ -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 |