From eae29fe1dcd76ead474050e5849a6e36ae1f8b29 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 15 Jun 2004 16:38:40 -0400 Subject: [PATCH] re PR tree-optimization/14107 (Return warnings don't work without optimizations enabled) PR tree-optimization/14107 * decl.c (finish_function): Warn about no return in all functions. From-SVN: r83198 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 5 ++++- gcc/testsuite/g++.dg/init/new10.C | 8 ++++++++ gcc/testsuite/g++.dg/warn/Wreturn-type-1.C | 11 +++++++++++ gcc/testsuite/g++.old-deja/g++.brendan/crash52.C | 3 ++- gcc/testsuite/g++.old-deja/g++.jason/report.C | 4 ++-- 6 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/init/new10.C create mode 100644 gcc/testsuite/g++.dg/warn/Wreturn-type-1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 518d73a17eb..7b61cfc338c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-06-12 Jason Merrill + + PR tree-optimization/14107 + * decl.c (finish_function): Warn about no return in all functions. + 2004-06-15 Paolo Bonzini * cp-tree.h (struct language_function): Remove cannot_inline. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 44a83d4345c..92c6cf03976 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10803,10 +10803,13 @@ finish_function (int flags) && !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)) + && !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 diff --git a/gcc/testsuite/g++.dg/init/new10.C b/gcc/testsuite/g++.dg/init/new10.C new file mode 100644 index 00000000000..e19629bc00b --- /dev/null +++ b/gcc/testsuite/g++.dg/init/new10.C @@ -0,0 +1,8 @@ +// PR c++/14452 +// We got confused trying to preevaluate the new-initializer. + +struct S {}; +void foo (bool b) +{ + new S(b ? S() : S()); +} diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C new file mode 100644 index 00000000000..fb9a8629139 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C @@ -0,0 +1,11 @@ +// PR c++/11725 +// { dg-options "-Wreturn-type" } + +template +struct A +{ + int foo() + { + throw "Stop"; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C index 9e72fb5cbb0..95c6a08322e 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C @@ -10,4 +10,5 @@ public: A &f(A &a) {// { dg-error "" } new decl.* std::cout << "Blah\n"; -} +} // { dg-warning "" } no return + diff --git a/gcc/testsuite/g++.old-deja/g++.jason/report.C b/gcc/testsuite/g++.old-deja/g++.jason/report.C index 13557f166ef..0149129fefe 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/report.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/report.C @@ -56,7 +56,7 @@ bar2 baz (X::Y y) bar2 wa [5]; wa[0] = baz(f); undef2 (1); // { dg-error "" } implicit declaration -} +} // { dg-warning "" } no return int ninny () { @@ -71,4 +71,4 @@ int ninny () int darg (char X::*p) { undef3 (1); // { dg-error "" } implicit declaration -} +} // { dg-warning "" } no return -- 2.30.2