On 11/15/2017 11:04 AM, Jakub Jelinek wrote: > On Wed, Nov 15, 2017 at 10:54:23AM +0100, Martin Liška wrote: >> gcc/c/ChangeLog: >> >> 2017-11-15 Martin Liska <mli...@suse.cz> >> >> * c-decl.c (grokdeclarator): >> Compare warn_return_type for greater than zero. >> (start_function): Likewise. >> (finish_function): Likewise. >> * c-typeck.c (c_finish_return): Likewise. >> >> gcc/cp/ChangeLog: >> >> 2017-11-15 Martin Liska <mli...@suse.cz> >> >> * decl.c (finish_function): >> Compare warn_return_type for greater than zero. >> * semantics.c (finish_return_stmt): Likewise. > > The c/cp changes aren't really needed, are they? Because > in that case you guarantee in the post options handling it is > 0 or 1.
Yep, you're right! > > The rest looks good (except for Ada that Eric doesn't want to change). > > Jakub > Done that and I'm going to install the patch. Martin
>From c0934d0be85d40762d4bafbf9991b167b711736e Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Wed, 15 Nov 2017 09:16:23 +0100 Subject: [PATCH] Disable -Wreturn-type by default in all languages other from C++. gcc/ChangeLog: 2017-11-15 Martin Liska <mli...@suse.cz> * tree-cfg.c (pass_warn_function_return::execute): Compare warn_return_type for greater than zero. gcc/fortran/ChangeLog: 2017-11-15 Martin Liska <mli...@suse.cz> * options.c (gfc_post_options): Do not set default value of warn_return_type. * trans-decl.c (gfc_trans_deferred_vars): Compare warn_return_type for greater than zero. (generate_local_decl): Likewise (gfc_generate_function_code): Likewise. --- gcc/fortran/options.c | 3 --- gcc/fortran/trans-decl.c | 8 ++++---- gcc/tree-cfg.c | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index c584a19e559..0ee6b7808d9 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -435,9 +435,6 @@ gfc_post_options (const char **pfilename) gfc_fatal_error ("Maximum subrecord length cannot exceed %d", MAX_SUBRECORD_LENGTH); - if (warn_return_type == -1) - warn_return_type = 0; - gfc_cpp_post_options (); if (gfc_option.allow_std & GFC_STD_F2008) diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 8efaae79ebc..60e7d8f79ee 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4198,7 +4198,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) break; } /* TODO: move to the appropriate place in resolve.c. */ - if (warn_return_type && el == NULL) + if (warn_return_type > 0 && el == NULL) gfc_warning (OPT_Wreturn_type, "Return value of function %qs at %L not set", proc_sym->name, &proc_sym->declared_at); @@ -5619,7 +5619,7 @@ generate_local_decl (gfc_symbol * sym) else if (sym->attr.flavor == FL_PROCEDURE) { /* TODO: move to the appropriate place in resolve.c. */ - if (warn_return_type + if (warn_return_type > 0 && sym->attr.function && sym->result && sym != sym->result @@ -6494,11 +6494,11 @@ gfc_generate_function_code (gfc_namespace * ns) if (result == NULL_TREE || artificial_result_decl) { /* TODO: move to the appropriate place in resolve.c. */ - if (warn_return_type && sym == sym->result) + if (warn_return_type > 0 && sym == sym->result) gfc_warning (OPT_Wreturn_type, "Return value of function %qs at %L not set", sym->name, &sym->declared_at); - if (warn_return_type) + if (warn_return_type > 0) TREE_NO_WARNING(sym->backend_decl) = 1; } if (result != NULL_TREE) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 9a2fa1d98ca..f08a0547f0f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9071,7 +9071,7 @@ pass_warn_function_return::execute (function *fun) /* If we see "return;" in some basic block, then we do reach the end without returning a value. */ - else if (warn_return_type + else if (warn_return_type > 0 && !TREE_NO_WARNING (fun->decl) && EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (fun)->preds) > 0 && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fun->decl)))) -- 2.14.3