aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-02-01 14:32:51 -0500
committerJason Merrill <jason@gcc.gnu.org>2002-02-01 14:32:51 -0500
commitefe49da0ba74c2fa1efe212d9c91cbdb1680c06d (patch)
treead77fd5a8517b02ca6dc9e00f1c365c442c92888 /gcc/cp/decl.c
parentf2d9afece3fb462b7abd8209a8d5d7119b28c0cd (diff)
downloadgcc-efe49da0ba74c2fa1efe212d9c91cbdb1680c06d.zip
gcc-efe49da0ba74c2fa1efe212d9c91cbdb1680c06d.tar.gz
gcc-efe49da0ba74c2fa1efe212d9c91cbdb1680c06d.tar.bz2
re PR c++/4872 (missed warning (no return) -- regression from 2.95)
PR c++/4872 * decl.c (finish_function): Warn about a non-void function with no return statement and no abnormal exit. * cp-tree.h (struct cp_language_function): Add returns_abnormally. (current_function_returns_abnormally): New macro. * call.c (build_call): Set it. From-SVN: r49407
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a5d9c64..097b562 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14247,6 +14247,18 @@ finish_function (flags)
if (!processing_template_decl && calls_setjmp_p (fndecl))
DECL_UNINLINABLE (fndecl) = 1;
+ /* Complain if there's just no return statement. */
+ if (!processing_template_decl
+ && TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
+ && !current_function_returns_value
+ && !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
+ 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. */
free_after_parsing (cfun);
/* Since we never call rest_of_compilation, we never clear