From patchwork Mon May 10 14:34:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1476476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=KwPVkfB+; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ff3Tc6ZyXz9rx6 for ; Tue, 11 May 2021 00:34:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFD9C383583C; Mon, 10 May 2021 14:34:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFD9C383583C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620657250; bh=6zUb7arpb5DBy68YVCJzDp/UkWo4nysceRCvn9pMcVk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KwPVkfB+b0gWFcawKwqi9G33vC4Qe+xdJCNMYUtU7FTmXu1yb6bXSXF/62miBkXzi VF2Ua7FYTjUqXpnGsdXCoBeDWAGFtMnyT97acIq0GiQPtzlqF4JIeS864wLCfTdg6f +Zeo8Mfb7G8CRq5xDYg2/L0Knb1/xMxOlWoQbqvY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id 6DE163854805; Mon, 10 May 2021 14:34:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6DE163854805 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.87.101] ([93.207.87.101]) by web-mail.gmx.net (3c-app-gmx-bs52.server.lan [172.19.170.105]) (via HTTP); Mon, 10 May 2021 16:34:05 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] PR fortran/98411 - [10/11/12 Regression] Pointless warning for static variables Date: Mon, 10 May 2021 16:34:05 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:GhWcprDLhKEKDeDeahO359ikosFhIRO56ZJEN0KHY3YjKta8rZHn6EkN7DgdbSBZeeFsw GlrhMLb88e5fVH5/gYEWtUDqmfduVt23PXdDFNhqUzMi0wndBC9tYpcHIi8gSrwVUll2kAlMML5Q LS41yRCR/KdFGp+9Am92AZ/B7tzXO0WoxnypYvdmuLMfCVsk6e+xrch4vRQpDvarhK+qt5gBqHaM NAW4yIOUkT4FQK5bi7oEJyObiQxX9QJi8gsXEpMyEZw0VUamN20dPQbP8Puk1RpXTnHCvAnvr8j2 6s= X-UI-Out-Filterresults: notjunk:1;V03:K0:orwqSJZOzb8=:ZOEYMCvsFX2A1I8q6uMBE9 L62pibD2EW8Zk5IwMzNAVv243z3KW8WpuGqokQk53IYTi+F9oq9qCoMsKiAGp1R0LNkbkRw4I 5xK88fxfwXfPIXhhtKtGL2Wl9A4p5QO2uGP9LqMxITZxpQ5uAjOxeBVj5xyi684cqqF+Mdik3 vHgIQcKEeulhxyAvshaoGImiu+0fjLXQEq5/hNiI9I17xzb28gwlJtPbKoO/uanc+DFq3mrJW J3OBEG9s/CxG+aTFna6bbXbZEnqxPu6ktkxqQMkWCNmcDr57JEAk13BS5H9qa/QnSqcsA9mm8 wU/5VstPqq1D6otbE68ZYt6hdlDvP99NsyyDKK0yp+eE86FECuJrpJVGjMBwmAm8D4KmrLLnN HYTou7NC048xfs7dltpPIFohJS0GAA5Mg2aRUOr4mLQyc759zJqoeI/0AkB/MtXsEhqCfjtFr KnxK2z7NEUkIq1PzhWuoThUIc50dcpgH7qQV+uYB2qEThuN2X2s4RbXdokuwTgd9qmUssXaZN 0Dz6ryqc27HuzQMg0eOPSlhX1RiGmZZzSz47v1ttrk6mqU4MFJhNSVu0n9WIdcCyqeyrleGH9 yRySRaLuZCIXeoCmoTxgC5E9j2zv3diPhXuYSPSp/InApudUP0gkXHAUeAgHTaIQANCPFzjbA 1cijKno2YcQ+4LsQ7nMSfydUZArhR9xbyoE+4Yad6M9HA9LR+eIJO6QxxcOVo7y9tnz2isCYs hpnt+oAHzzvaZddRS1ntgflksYMW9RdsKfNLm/eJcO3zca6GkbKoHKYTaTWizgVdjzEvtS7t8 294C+JHoeMhURq0L82Cfi+K/sQgg8d9eJ8wS8wDxTBsPF8M8ZGrWdj8M1bsGhR29WYlyi7D9s JBed8Hmz8XbanLBHDaO3VVr7CV9/2A7Ino5MTQqQ8vUeuhSLMQSsy8cMcig+ki X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" A simple, self-explaining patch to avoid a wrong warning. Regtested on x86_64-pc-linux-gnu. OK for mainline? Affected branches? Thanks, Harald PR fortran/98411 - Pointless warning for static variables Variables with explicit SAVE attribute cannot end up on the stack. There is no point in checking whether they should be moved off the stack to static storage. gcc/fortran/ChangeLog: PR fortran/98411 * trans-decl.c (gfc_finish_var_decl): Add check for explicit SAVE attribute. gcc/testsuite/ChangeLog: PR fortran/98411 * gfortran.dg/pr98411.f90: New test. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index cc9d85543ca..7cded0a3ede 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -738,6 +738,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) /* Keep variables larger than max-stack-var-size off stack. */ if (!(sym->ns->proc_name && sym->ns->proc_name->attr.recursive) && !sym->attr.automatic + && sym->attr.save != SAVE_EXPLICIT && INTEGER_CST_P (DECL_SIZE_UNIT (decl)) && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)) /* Put variable length auto array pointers always into stack. */ diff --git a/gcc/testsuite/gfortran.dg/pr98411.f90 b/gcc/testsuite/gfortran.dg/pr98411.f90 new file mode 100644 index 00000000000..249afaea419 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr98411.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-Wall -fautomatic -fmax-stack-var-size=100" } +! PR fortran/98411 - Pointless warning for static variables + +module try + implicit none + integer, save :: a(1000) +contains + subroutine initmodule + real, save :: b(1000) + logical :: c(1000) ! { dg-warning "moved from stack to static storage" } + a(1) = 42 + b(2) = 3.14 + c(3) = .true. + end subroutine initmodule +end module try