Commit 46cfb101 by Jason Merrill Committed by Jason Merrill

c-decl.c (finish_function): Only warn about missing return statement with -Wreturn-type.

        * c-decl.c (finish_function): Only warn about missing return
        statement with -Wreturn-type.
        * cp/decl.c (finish_function): Only warn about missing return
        statement with -Wreturn-type.

From-SVN: r50132
parent 022dcc46
2002-02-25 Jason Merrill <jason@redhat.com>
* c-decl.c (finish_function): Only warn about missing return
statement with -Wreturn-type.
Don Feb 28 11:24:30 CET 2002 Jan Hubicka <jh@suse.cz> Don Feb 28 11:24:30 CET 2002 Jan Hubicka <jh@suse.cz>
* cfgrtl.c (purge_dead_edges): Fix handling of EH edges. * cfgrtl.c (purge_dead_edges): Fix handling of EH edges.
......
...@@ -6809,7 +6809,8 @@ finish_function (nested) ...@@ -6809,7 +6809,8 @@ finish_function (nested)
finish_stmt_tree (&DECL_SAVED_TREE (fndecl)); finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
/* Complain if there's just no return statement. */ /* Complain if there's just no return statement. */
if (TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE if (warn_return_type
&& TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
&& !current_function_returns_value && !current_function_returns_null && !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort. */ /* Don't complain if we abort. */
&& !current_function_returns_abnormally && !current_function_returns_abnormally
...@@ -6817,9 +6818,9 @@ finish_function (nested) ...@@ -6817,9 +6818,9 @@ finish_function (nested)
&& !MAIN_NAME_P (DECL_NAME (fndecl)) && !MAIN_NAME_P (DECL_NAME (fndecl))
/* Or if they didn't actually specify a return type. */ /* Or if they didn't actually specify a return type. */
&& !C_FUNCTION_IMPLICIT_INT (fndecl) && !C_FUNCTION_IMPLICIT_INT (fndecl)
/* If we have -Wreturn-type, let flow 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. */
&& (!warn_return_type || DECL_INLINE (fndecl))) && DECL_INLINE (fndecl))
warning ("no return statement in function returning non-void"); warning ("no return statement in function returning non-void");
/* Clear out memory we no longer need. */ /* Clear out memory we no longer need. */
......
2002-02-28 Jason Merrill <jason@redhat.com>
* decl.c (finish_function): Only warn about missing return
statement with -Wreturn-type.
2002-02-28 Neil Booth <neil@daikokuya.demon.co.uk> 2002-02-28 Neil Booth <neil@daikokuya.demon.co.uk>
* class.c (build_clone): Update. * class.c (build_clone): Update.
......
...@@ -14224,15 +14224,16 @@ finish_function (flags) ...@@ -14224,15 +14224,16 @@ finish_function (flags)
DECL_UNINLINABLE (fndecl) = 1; DECL_UNINLINABLE (fndecl) = 1;
/* Complain if there's just no return statement. */ /* Complain if there's just no return statement. */
if (!processing_template_decl if (warn_return_type
&& !processing_template_decl
&& TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
&& !current_function_returns_value && !current_function_returns_null && !current_function_returns_value && !current_function_returns_null
&& !DECL_NAME (DECL_RESULT (fndecl))
/* Don't complain if we abort or throw. */ /* Don't complain if we abort or throw. */
&& !current_function_returns_abnormally && !current_function_returns_abnormally
/* If we have -Wreturn-type, let flow complain. Unless we're an && !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. */ inline function, as we might never be compiled separately. */
&& (!warn_return_type || DECL_INLINE (fndecl))) && DECL_INLINE (fndecl))
warning ("no return statement in function returning non-void"); warning ("no return statement in function returning non-void");
/* Clear out memory we no longer need. */ /* Clear out memory we no longer need. */
......
...@@ -9,7 +9,7 @@ public: ...@@ -9,7 +9,7 @@ public:
X::x() X::x()
{ // ERROR - { // ERROR -
} // WARNING - no return }
X::~x() X::~x()
{ // ERROR - { // ERROR -
......
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