From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4297 invoked by alias); 17 Jun 2014 16:52:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4286 invoked by uid 89); 17 Jun 2014 16:52:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: batou.ecranbleu.org Received: from batou.ecranbleu.org (HELO batou.ecranbleu.org) (88.190.32.89) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Jun 2014 16:52:09 +0000 Received: by batou.ecranbleu.org (Postfix, from userid 999) id 0CADF122578; Tue, 17 Jun 2014 18:51:35 +0200 (CEST) Received: from [192.168.12.5] (unknown [192.168.12.5]) (Authenticated sender: sylvestredeb@ledru.info) by batou.ecranbleu.org (Postfix) with ESMTPSA id 43D5D122319; Tue, 17 Jun 2014 18:51:25 +0200 (CEST) Message-ID: <53A07226.4040803@debian.org> Date: Tue, 17 Jun 2014 16:52:00 -0000 From: Sylvestre Ledru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: "Joseph S. Myers" CC: gcc-patches@gcc.gnu.org, Jason Merrill Subject: Re: [Patch] PR55189 enable -Wreturn-type by default References: <538F7856.1090104@debian.org> <53903961.9030501@debian.org> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020202010505090101020304" X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg01365.txt.bz2 This is a multi-part message in MIME format. --------------020202010505090101020304 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 873 On 05/06/2014 20:01, Joseph S. Myers wrote: > >> Initially, I implemented -Wmissing-return to manage this case ( >> https://gcc.gnu.org/ml/gcc-patches/2014-01/msg00820.html ) but Jason >> suggested to remove that: >> https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01033.html >> (I don't have a strong opinion on the subject). > I think splitting the option like that makes sense. Compatibility > indicates that -Wreturn-type and -Wall should still enable > -Wmissing-return, but only the other pieces of -Wreturn-type should be > enabled by default, at least for C. (Enabling -Wimplicit-int by default > might be a good starting point.) OK. As attachment, you will find a potential implementation. Is that what you expect? > Also, at least one testsuite change in your patch is wrong. OK. Thanks. I've probably made other (I update +1300 of them) Thanks Sylvestre --------------020202010505090101020304 Content-Type: text/x-patch; name="0002-Enable-Wimplicit-by-default.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Enable-Wimplicit-by-default.patch" Content-length: 758 >From 1b936c618c58dc0e899fa9f56013de48f7e4dcd6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 17 Jun 2014 18:48:29 +0200 Subject: [PATCH 2/2] Enable Wimplicit by default --- gcc/c-family/c.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 050d400..9b9ede7 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -460,7 +460,7 @@ C ObjC Var(warn_implicit_function_declaration) Init(-1) Warning LangEnabledBy(C Warn about implicit function declarations Wimplicit-int -C ObjC Var(warn_implicit_int) Warning LangEnabledBy(C ObjC,Wimplicit) +C ObjC Var(warn_implicit_int) Warning Warn when a declaration does not specify a type Wimport -- 2.0.0 --------------020202010505090101020304 Content-Type: text/x-patch; name="0001-Introduce-Wmissing-return-Was-part-of-Wreturn-type-w.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Introduce-Wmissing-return-Was-part-of-Wreturn-type-w.pa"; filename*1="tch" Content-length: 4030 >From 80cd3dff34f74058ab66b69e0e01a05eaf686338 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 17 Jun 2014 18:48:12 +0200 Subject: [PATCH 1/2] Introduce -Wmissing-return (Was part of -Wreturn-type which is now enabled by default) --- gcc/c-family/c.opt | 4 ++++ gcc/doc/invoke.texi | 10 +++++++++- gcc/fortran/options.c | 4 ++++ gcc/tree-cfg.c | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 91f8275..050d400 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -697,6 +697,10 @@ Wreturn-type C ObjC C++ ObjC++ Var(warn_return_type) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) Warn whenever a function's return type defaults to \"int\" (C), or about inconsistent return types (C++) +Wmissing-return +C ObjC C++ ObjC++ Var(warn_missing_return) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) +Warn whenever control may reach end of non-void function + Wselector ObjC ObjC++ Var(warn_selector) Warning Warn if a selector has multiple methods diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9a34f1c..9911e86 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -258,7 +258,7 @@ Objective-C and Objective-C++ Dialects}. -Winvalid-pch -Wlarger-than=@var{len} -Wunsafe-loop-optimizations @gol -Wlogical-op -Wlogical-not-parentheses -Wlong-long @gol -Wmain -Wmaybe-uninitialized -Wmissing-braces -Wmissing-field-initializers @gol --Wmissing-include-dirs @gol +-Wmissing-include-dirs -Wmissing-return @gol -Wno-multichar -Wnonnull -Wno-overflow -Wopenmp-simd @gol -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol @@ -3327,6 +3327,7 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}. -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol -Wmaybe-uninitialized @gol -Wmissing-braces @r{(only for C/ObjC)} @gol +-Wmissing-return @gol -Wnonnull @gol -Wopenmp-simd @gol -Wparentheses @gol @@ -3657,6 +3658,13 @@ the following example, the initializer for @samp{a} is not fully bracketed, but that for @samp{b} is fully bracketed. This warning is enabled by @option{-Wall} in C. +@item -Wmissing-return +@opindex Wmissing-return +@opindex Wno-missing-return +Warn whenever falling off the end of the function body (I.e. without +any return). +This warning is enabled by @option{-Wall} for C and C++. + @smallexample int a[2][2] = @{ 0, 1, 2, 3 @}; int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index a2b91ca..fe71230 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -698,6 +698,10 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.warn_line_truncation = value; break; + case OPT_Wmissing_return: + warn_missing_return = value; + break; + case OPT_Wrealloc_lhs: gfc_option.warn_realloc_lhs = value; break; diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e824619..2fd342e 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8265,7 +8265,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_missing_return && !TREE_NO_WARNING (fun->decl) && EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (fun)->preds) > 0 && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fun->decl)))) @@ -8280,7 +8280,7 @@ pass_warn_function_return::execute (function *fun) location = gimple_location (last); if (location == UNKNOWN_LOCATION) location = fun->function_end_locus; - warning_at (location, OPT_Wreturn_type, "control reaches end of non-void function"); + warning_at (location, OPT_Wmissing_return, "control reaches end of non-void function"); TREE_NO_WARNING (fun->decl) = 1; break; } -- 2.0.0 --------------020202010505090101020304--