This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to work around tree-optimization/14107
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Jun 2004 16:38:11 -0400
- Subject: PATCH to work around tree-optimization/14107
Even though we don't currently have enough flow information at -O0 for the
-Wreturn-type warnings, we can at least warn about a function with no
return statement.
Tested x86_64-pc-linux-gnu, applied to trunk.
2004-06-12 Jason Merrill <jason@redhat.com>
PR tree-optimization/14107
* decl.c (finish_function): Warn about no return in all functions.
*** ./gcc/cp/decl.c.~1~ 2004-06-15 16:31:28.000000000 -0400
--- ./gcc/cp/decl.c 2004-06-15 16:30:15.000000000 -0400
*************** finish_function (int flags)
*** 10803,10812 ****
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */
&& !current_function_returns_abnormally
! && !DECL_NAME (DECL_RESULT (fndecl))
/* Normally, with -Wreturn-type, flow will complain. Unless we're an
inline function, as we might never be compiled separately. */
&& (DECL_INLINE (fndecl) || processing_template_decl))
warning ("no return statement in function returning non-void");
/* Store the end of the function, so that we get good line number
--- 10803,10815 ----
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */
&& !current_function_returns_abnormally
! && !DECL_NAME (DECL_RESULT (fndecl)))
! #if 0
! /* Enable this for all functions until bug 14107 is fixed properly. */
/* Normally, with -Wreturn-type, flow will complain. Unless we're an
inline function, as we might never be compiled separately. */
&& (DECL_INLINE (fndecl) || processing_template_decl))
+ #endif
warning ("no return statement in function returning non-void");
/* Store the end of the function, so that we get good line number
*** ./gcc/testsuite/g++.old-deja/g++.brendan/crash52.C.~1~ 2004-06-15 16:31:28.000000000 -0400
--- ./gcc/testsuite/g++.old-deja/g++.brendan/crash52.C 2004-06-12 01:46:32.000000000 -0400
*************** public:
*** 10,13 ****
A &f(A &a) {// { dg-error "" } new decl.*
std::cout << "Blah\n";
! }
--- 10,14 ----
A &f(A &a) {// { dg-error "" } new decl.*
std::cout << "Blah\n";
! } // { dg-warning "" } no return
!
*** ./gcc/testsuite/g++.old-deja/g++.jason/report.C.~1~ 2004-06-15 16:31:28.000000000 -0400
--- ./gcc/testsuite/g++.old-deja/g++.jason/report.C 2004-06-12 02:07:43.000000000 -0400
*************** bar2 baz (X::Y y)
*** 56,62 ****
bar2 wa [5];
wa[0] = baz(f);
undef2 (1); // { dg-error "" } implicit declaration
! }
int ninny ()
{
--- 56,62 ----
bar2 wa [5];
wa[0] = baz(f);
undef2 (1); // { dg-error "" } implicit declaration
! } // { dg-warning "" } no return
int ninny ()
{
*************** int ninny ()
*** 71,74 ****
int darg (char X::*p)
{
undef3 (1); // { dg-error "" } implicit declaration
! }
--- 71,74 ----
int darg (char X::*p)
{
undef3 (1); // { dg-error "" } implicit declaration
! } // { dg-warning "" } no return