diff options
author | Jason Merrill <jason@redhat.com> | 2002-02-28 08:30:04 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-02-28 08:30:04 -0500 |
commit | 46cfb1010def3669407095b58a1ef83ad90acf62 (patch) | |
tree | ad97c2c9c6937f818499e1e71ba0ae8c21869572 /gcc | |
parent | 022dcc46051ffd0114ac3382cc7e50928f17d995 (diff) | |
download | gcc-46cfb1010def3669407095b58a1ef83ad90acf62.zip gcc-46cfb1010def3669407095b58a1ef83ad90acf62.tar.gz gcc-46cfb1010def3669407095b58a1ef83ad90acf62.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-decl.c | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/crash25.C | 2 |
5 files changed, 20 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 165147b..4aa2514 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 21ff5ee..f465875 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 410479c..3ca4e5b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4d912cd..d4ea80d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. */ diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash25.C b/gcc/testsuite/g++.old-deja/g++.other/crash25.C index 0c39be8..2f471fb 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/crash25.C +++ b/gcc/testsuite/g++.old-deja/g++.other/crash25.C @@ -9,7 +9,7 @@ public: X::x() { // ERROR - -} // WARNING - no return +} X::~x() { // ERROR - |