Commit eae29fe1 by Jason Merrill Committed by Jason Merrill

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
parent 0566b51e
2004-06-12 Jason Merrill <jason@redhat.com>
PR tree-optimization/14107
* decl.c (finish_function): Warn about no return in all functions.
2004-06-15 Paolo Bonzini <bonzini@gnu.org> 2004-06-15 Paolo Bonzini <bonzini@gnu.org>
* cp-tree.h (struct language_function): Remove cannot_inline. * cp-tree.h (struct language_function): Remove cannot_inline.
......
...@@ -10803,10 +10803,13 @@ finish_function (int flags) ...@@ -10803,10 +10803,13 @@ finish_function (int flags)
&& !current_function_returns_value && !current_function_returns_null && !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */ /* Don't complain if we abort or throw. */
&& !current_function_returns_abnormally && !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 /* Normally, with -Wreturn-type, flow will complain. Unless we're an
inline function, as we might never be compiled separately. */ inline function, as we might never be compiled separately. */
&& (DECL_INLINE (fndecl) || processing_template_decl)) && (DECL_INLINE (fndecl) || processing_template_decl))
#endif
warning ("no return statement in function returning non-void"); warning ("no return statement in function returning non-void");
/* 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
......
// PR c++/14452
// We got confused trying to preevaluate the new-initializer.
struct S {};
void foo (bool b)
{
new S(b ? S() : S());
}
// PR c++/11725
// { dg-options "-Wreturn-type" }
template <class T>
struct A
{
int foo()
{
throw "Stop";
}
};
...@@ -10,4 +10,5 @@ public: ...@@ -10,4 +10,5 @@ public:
A &f(A &a) {// { dg-error "" } new decl.* A &f(A &a) {// { dg-error "" } new decl.*
std::cout << "Blah\n"; std::cout << "Blah\n";
} } // { dg-warning "" } no return
...@@ -56,7 +56,7 @@ bar2 baz (X::Y y) ...@@ -56,7 +56,7 @@ bar2 baz (X::Y y)
bar2 wa [5]; bar2 wa [5];
wa[0] = baz(f); wa[0] = baz(f);
undef2 (1); // { dg-error "" } implicit declaration undef2 (1); // { dg-error "" } implicit declaration
} } // { dg-warning "" } no return
int ninny () int ninny ()
{ {
...@@ -71,4 +71,4 @@ int ninny () ...@@ -71,4 +71,4 @@ int ninny ()
int darg (char X::*p) int darg (char X::*p)
{ {
undef3 (1); // { dg-error "" } implicit declaration undef3 (1); // { dg-error "" } implicit declaration
} } // { dg-warning "" } no return
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