This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch to not warn about infinite loops


Actually, here's the patch I've been waiting for someone to ask me to
write:

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

*** c-decl.c.~1~	Mon Feb 25 14:15:16 2002
--- c-decl.c	Mon Feb 25 14:06:22 2002
*************** finish_function (nested)
*** 6938,6944 ****
    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
        && !current_function_returns_value && !current_function_returns_null
        /* Don't complain if we abort.  */
        && !current_function_returns_abnormally
--- 6938,6945 ----
    finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
  
    /* Complain if there's just no return statement.  */
!   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
*************** finish_function (nested)
*** 6946,6954 ****
        && !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
  	 inline function, as we might never be compiled separately.  */
!       && (!warn_return_type || DECL_INLINE (fndecl)))
      warning ("no return statement in function returning non-void");
  
    /* Clear out memory we no longer need.  */
--- 6947,6955 ----
        && !MAIN_NAME_P (DECL_NAME (fndecl))
        /* Or if they didn't actually specify a return type.  */
        && !C_FUNCTION_IMPLICIT_INT (fndecl)
!       /* Normally, with -Wreturn-type, flow will complain.  Unless we're an
  	 inline function, as we might never be compiled separately.  */
!       && DECL_INLINE (fndecl))
      warning ("no return statement in function returning non-void");
  
    /* Clear out memory we no longer need.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]