From patchwork Sun Oct 21 10:38:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 192986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 929152C0096 for ; Sun, 21 Oct 2012 21:38:38 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351420719; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=zPyfq8s72DRYa2NqGky1aTA8SLw=; b=ajq3i83MgUq52sq WgK17NYwItlwuNIn/cReZiZnvBERtP1qO7FMUkxvMuE72jolHnCF8hZhXGgrEswn eRg/MoDXLdZVvAJNVJF1RaYCT1LQyg2hT1rHSkLM41R/aiKz9+RQ5OCCDGOb7otc gU1j/SRnh4T/dXGyUgRFW0rFazQ8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=N7joiFEPLyVsFslDWBBftR/Mrt/ai8IMVAPOR63kYEx+L89+/g9p7CLOrcAVsI GYBp6Pm326HdmzynJYr0foSbWfqzEE3zzYrqNwZMjyudG9PbkP3MRVcOepiHvxg6 1UZB9SOQsg4/zT7mdwsmeF8PZc9g+0FyJZuYHEBDyzLsY=; Received: (qmail 8654 invoked by alias); 21 Oct 2012 10:38:33 -0000 Received: (qmail 8634 invoked by uid 22791); 21 Oct 2012 10:38:32 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 21 Oct 2012 10:38:23 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 09AF5127BF; Sun, 21 Oct 2012 12:38:21 +0200 (CEST) Received: from [192.168.0.106] (xdsl-78-35-147-82.netcologne.de [78.35.147.82]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id B622311DBA; Sun, 21 Oct 2012 12:38:18 +0200 (CEST) Message-ID: <5083D099.8080708@netcologne.de> Date: Sun, 21 Oct 2012 12:38:17 +0200 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: Janus Weil CC: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: *ping* [patch, fortran] Handle -Wextra, -fcompare-reals is implied with -Wextra References: <505F69DF.5090706@netcologne.de> <5065D3F1.2040607@netcologne.de> <5082F792.9050004@netcologne.de> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi Janus, > In the docu of -Wall, there is a list of which switches are included, > but -Wc-binding-type is missing. Maybe you can add it? > > And how about also adding a short docu paragraph for Wextra? I've added both items to the documentation as you suggested, and committed as rev. 192649. Here is the patch as I committed it. Thanks a lot for your review! Now we can start thinking if we want to add other flags to -Wextra. Regards Thomas 012-10-21 Thomas Koenig PR fortran/54465 * lang.opt (Wextra): Add. * invoke.texi: Document that -Wc-binding-type, -Wconversion and -Wline-truncation are implied by -Wall. Document that -Wcompare-reals is implied by -Wextra. Document -Wextra. * options.c (set_Wextra): New function. (gfc_handle_option): Handle -Wextra. 2012-10-21 Thomas Koenig PR fortran/54465 * gfortran.dg/wextra_1.f: New test. Index: lang.opt =================================================================== --- lang.opt (revision 192638) +++ lang.opt (working copy) @@ -230,6 +230,10 @@ Wconversion-extra Fortran Warning Warn about most implicit conversions +Wextra +Fortran Warning +Print extra (possibly unwanted) warnings + Wfunction-elimination Fortran Warning Warn about function call elimination Index: invoke.texi =================================================================== --- invoke.texi (revision 192638) +++ invoke.texi (working copy) @@ -727,7 +727,7 @@ warnings. Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes @option{-Waliasing}, @option{-Wampersand}, -@option{-Wconversion}, @option{-Wsurprising}, +@option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type}, @option{-Wintrinsics-std}, @option{-Wno-tabs}, @option{-Wintrinsic-shadow}, @option{-Wline-truncation}, @option{-Wtarget-lifetime}, @option{-Wreal-q-constant} and @option{-Wunused}. @@ -778,7 +778,8 @@ avoid such temporaries. Warn if the a variable might not be C interoperable. In particular, warn if the variable has been declared using an intrinsic type with default kind instead of using a kind parameter defined for C interoperability in the -intrinsic @code{ISO_C_Binding} module. +intrinsic @code{ISO_C_Binding} module. This option is implied by +@option{-Wall}. @item -Wcharacter-truncation @opindex @code{Wcharacter-truncation} @@ -788,7 +789,8 @@ Warn when a character assignment will truncate the @item -Wline-truncation @opindex @code{Wline-truncation} @cindex warnings, line truncation -Warn when a source code line will be truncated. +Warn when a source code line will be truncated. This option is +implied by @option{-Wall}. @item -Wconversion @opindex @code{Wconversion} @@ -803,6 +805,14 @@ the expression after conversion. Implied by @optio @cindex conversion Warn about implicit conversions between different types and kinds. +@item -Wextra +@opindex @code{Wextra} +@cindex extra warnings +@cindex warnings, extra +Enables some warning options for usages of language features which +may be problematic. This currently includes @option{-Wcompare-reals} +and @option{-Wunused-parameter}. + @item -Wimplicit-interface @opindex @code{Wimplicit-interface} @cindex warnings, implicit interface @@ -884,7 +894,7 @@ encountered, which yield an UNDERFLOW during compi Warn if a user-defined procedure or module procedure has the same name as an intrinsic; in this case, an explicit interface or @code{EXTERNAL} or @code{INTRINSIC} declaration might be needed to get calls later resolved to -the desired intrinsic/procedure. +the desired intrinsic/procedure. This option is implied by @option{-Wall}. @item -Wunused-dummy-argument @opindex @code{Wunused-dummy-argument} @@ -939,6 +949,7 @@ allocatable variable; this includes scalars and de @item -Wcompare-reals @opindex @code{Wcompare-reals} Warn when comparing real or complex types for equality or inequality. +This option is implied by @option{-Wextra}. @item -Wtarget-lifetime @opindex @code{Wtargt-lifetime} Index: trans.c =================================================================== --- trans.c (revision 192638) +++ trans.c (working copy) @@ -814,26 +814,23 @@ gfc_allocate_allocatable (stmtblock_t * block, tre } -/* Free a given variable, if it's not NULL. */ +/* Free a given variable. If it is NULL, free takes care of this + automatically. */ tree gfc_call_free (tree var) { stmtblock_t block; - tree tmp, cond, call; + tree call; if (TREE_TYPE (var) != TREE_TYPE (pvoid_type_node)) var = fold_convert (pvoid_type_node, var); gfc_start_block (&block); var = gfc_evaluate_now (var, &block); - cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, var, - build_int_cst (pvoid_type_node, 0)); call = build_call_expr_loc (input_location, builtin_decl_explicit (BUILT_IN_FREE), 1, var); - tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, call, - build_empty_stmt (input_location)); - gfc_add_expr_to_block (&block, tmp); + gfc_add_expr_to_block (&block, call); return gfc_finish_block (&block); } @@ -861,11 +858,10 @@ gfc_call_free (tree var) } } - In this front-end version, status doesn't have to be GFC_INTEGER_4. - Moreover, if CAN_FAIL is true, then we will not emit a runtime error, - even when no status variable is passed to us (this is used for - unconditional deallocation generated by the front-end at end of - each procedure). + In this front-end version, status doesn't have to be GFC_INTEGER_4. If + CAN_FAIL is true, no status variable is passed and we are not dealing with + a coarray, we will simply call free(). This is used for unconditional + deallocation generated by the front-end at end of each procedure. If a runtime-message is possible, `expr' must point to the original expression being deallocated for its locus and variable name. @@ -890,6 +886,14 @@ gfc_deallocate_with_status (tree pointer, tree sta STRIP_NOPS (pointer); } + else if (can_fail && status == NULL_TREE) + { + tmp = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_FREE), 1, + fold_convert (pvoid_type_node, pointer)); + return tmp; + } + cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pointer, build_int_cst (TREE_TYPE (pointer), 0)); Index: options.c =================================================================== --- options.c (revision 192638) +++ options.c (working copy) @@ -483,8 +483,15 @@ set_Wall (int setting) warn_maybe_uninitialized = setting; } +/* Set the options for -Wextra. */ static void +set_Wextra (int setting) +{ + gfc_option.warn_compare_reals = setting; +} + +static void gfc_handle_module_path_options (const char *arg) { @@ -653,6 +660,15 @@ gfc_handle_option (size_t scode, const char *arg, gfc_option.warn_conversion_extra = value; break; + case OPT_Wextra: + handle_generated_option (&global_options, &global_options_set, + OPT_Wunused_parameter, NULL, value, + gfc_option_lang_mask (), kind, loc, + handlers, global_dc); + set_Wextra (value); + + break; + case OPT_Wfunction_elimination: gfc_option.warn_function_elimination = value; break;