* c-decl.c (finish_function): Only warn about missing return
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Feb 2002 13:30:04 +0000 (13:30 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Feb 2002 13:30:04 +0000 (13:30 +0000)
        statement with -Wreturn-type.
        * cp/decl.c (finish_function): Only warn about missing return
        statement with -Wreturn-type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50132 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.other/crash25.C

index 165147b..4aa2514 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * cfgrtl.c (purge_dead_edges): Fix handling of EH edges.
index 21ff5ee..f465875 100644 (file)
@@ -6809,7 +6809,8 @@ finish_function (nested)
   finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
 
   /* 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
       /* Don't complain if we abort.  */
       && !current_function_returns_abnormally
@@ -6817,9 +6818,9 @@ finish_function (nested)
       && !MAIN_NAME_P (DECL_NAME (fndecl))
       /* Or if they didn't actually specify a return type.  */
       && !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.  */
-      && (!warn_return_type || DECL_INLINE (fndecl)))
+      && DECL_INLINE (fndecl))
     warning ("no return statement in function returning non-void");
 
   /* Clear out memory we no longer need.  */
index 410479c..3ca4e5b 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * class.c (build_clone): Update.
index 4d912cd..d4ea80d 100644 (file)
@@ -14224,15 +14224,16 @@ finish_function (flags)
     DECL_UNINLINABLE (fndecl) = 1;
 
   /* 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
       && !current_function_returns_value && !current_function_returns_null
-      && !DECL_NAME (DECL_RESULT (fndecl))
       /* Don't complain if we abort or throw.  */
       && !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.  */
-      && (!warn_return_type || DECL_INLINE (fndecl)))
+      && DECL_INLINE (fndecl))
     warning ("no return statement in function returning non-void");
     
   /* Clear out memory we no longer need.  */
index 0c39be8..2f471fb 100644 (file)
@@ -9,7 +9,7 @@ public:
 
 X::x()
 {                              // ERROR - 
-} // WARNING - no return
+}
 
 X::~x()
 {                              // ERROR -