From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31345 invoked by alias); 11 Jan 2010 18:18:03 -0000 Received: (qmail 31179 invoked by uid 48); 11 Jan 2010 18:17:49 -0000 Date: Mon, 11 Jan 2010 18:18:00 -0000 Message-ID: <20100111181749.31178.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/42674] [4.4/4.5 Regression] Bogus "no return statement in function returning non-void" warning In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "manu at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg01251.txt.bz2 ------- Comment #3 from manu at gcc dot gnu dot org 2010-01-11 18:17 ------- There must be some reason why this: 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 are no-return. */ && !current_function_returns_abnormally /* Don't warn for main(). */ && !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, but we might optimize out static functions. */ && !TREE_PUBLIC (fndecl)) { warning (OPT_Wreturn_type, "no return statement in function returning non-void"); TREE_NO_WARNING (fndecl) = 1; } is not triggered in C (even without the __noreturn__?), whereas this is: if (warn_return_type && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE && !dependent_type_p (TREE_TYPE (fntype)) && !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)) && !TREE_NO_WARNING (fndecl) /* Structor return values (if any) are set by the compiler. */ && !DECL_CONSTRUCTOR_P (fndecl) && !DECL_DESTRUCTOR_P (fndecl)) { warning (OPT_Wreturn_type, "no return statement in function returning non-void"); TREE_NO_WARNING (fndecl) = 1; } I think this may be actually two bugs, one is the noreturn which should set current_function_returns_abnormally to true, so no warning. Another is that the function is not marked as never returning because of the infinite loop. -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42674