From patchwork Thu Sep 19 13:40:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1164636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509294-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=codethink.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Jp/yJHiv"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YyfZ5bGNz9sN1 for ; Thu, 19 Sep 2019 23:40:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=p2UYQX3/zTNo9BhLj6660FfdrRygKJ0E9M5R+0fLKCU65qYmfy ONhWphSrkaP9bsXHUXyw66uvMuNz3/OkrgwLZSvt8R+0CGmFJTFGxNcfMjPYUcQf DZqbNUEMedp4BCU9s9qpYIzovxOdWGdWADRLNaP22t3Wr3VLZ4DInFQTk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=S2Gmlxc2vRxI4zlrHj9hZnLnVPY=; b=Jp/yJHiv/VyJsVN9NjuS u56P+aUgK+GkNs2qRKRroXMaI338KOVTY2pxh056pYJZalpgIWwjZiy4D8hE2fa2 rQY2a8dwOVe6rHyWZutO4uFp1d7c8U5zu0+UhSh1F6eudcwLlOTBxEZKSxIDYRa1 DbVv6DONw9BdQdC6gnMUYGw= Received: (qmail 96934 invoked by alias); 19 Sep 2019 13:40:41 -0000 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 Received: (qmail 96912 invoked by uid 89); 19 Sep 2019 13:40:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=regarded X-HELO: imap1.codethink.co.uk Received: from imap1.codethink.co.uk (HELO imap1.codethink.co.uk) (176.9.8.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 13:40:39 +0000 Received: from [167.98.27.226] (helo=[10.35.4.88]) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1iAwfj-0002oC-VB; Thu, 19 Sep 2019 14:40:36 +0100 To: gcc-patches , fortran From: Mark Eggleston Subject: [PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review Message-ID: <0ddfc9df-384a-98eb-f950-57705d1a5faf@codethink.co.uk> Date: Thu, 19 Sep 2019 14:40:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 The following warning is produced when -fno-automatic and -frecursive are used at the same time: f951: Warning: Flag '-fno-automatic' overwrites '-frecursive' This is a reasonable warning, however, recursion can be used with the -fno-automatic flag where recursion is enabled using -frecusive instead of explicitly using the recursive keyword. If all relevant subroutines local variables are explicitly declared automatic then recursion will work and the warning becomes a nuisance when -Werror is used in the build environment. This patch allows the warning to be switched off using a new option, -Woverwrite-recursive, initialised to on. I don't have a test case for this as I don't know how to test for a warning that isn't related to a line of code. It is a very simple patch, can the test case be omitted? ChangeLog gcc/fortran     Mark Eggleston      * lang.opt: Add option -Woverwrite-recursive initialised as on.     * option.c (gfc_post_options): Output warning only if it is enabled. From cfdcde8229ebed15304c1adb8085365f8ad5970a Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Tue, 16 Apr 2019 09:09:12 +0100 Subject: [PATCH 09/12] Suppress warning with -Wno-overwrite-recursive The message "Warning: Flag '-fno-automatic' overwrites '-frecursive'" is output by default when -fno-automatic and -frecursive are used together. It warns that recursion may be broken, however if all the relavent variables in the recursive procedure have automatic attributes the warning is unnecessary so -Wno-overwrite-recursive can be used to suppress it. This will allow compilation when warnings are regarded as errors. Suppress warning with -Wno-overwrite-recursive --- gcc/fortran/lang.opt | 4 ++++ gcc/fortran/options.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 2aba57d00b5..7d9fd3e048c 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -289,6 +289,10 @@ Wopenmp-simd Fortran ; Documented in C +Woverwrite-recursive +Fortran Warning Var(warn_overwrite_recursive) Init(1) +Warn that -fno-automatic may break recursion. + Wpedantic Fortran ; Documented in common.opt diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 03e14338578..1721f93f673 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -411,7 +411,7 @@ gfc_post_options (const char **pfilename) && flag_max_stack_var_size != 0) gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>", flag_max_stack_var_size); - else if (!flag_automatic && flag_recursive) + else if (!flag_automatic && flag_recursive && warn_overwrite_recursive) gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>"); else if (!flag_automatic && flag_openmp) gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by " -- 2.11.0