From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 7FA1E388C02E; Fri, 28 May 2021 18:19:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FA1E388C02E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-9871] PR fortran/98411 - Pointless warning for static variables X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 4350d43a2e633e6b3ddb4452f86e74a1213af657 X-Git-Newrev: 799cf16051844f80d09526f17194373902254708 Message-Id: <20210528181923.7FA1E388C02E@sourceware.org> Date: Fri, 28 May 2021 18:19:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2021 18:19:23 -0000 https://gcc.gnu.org/g:799cf16051844f80d09526f17194373902254708 commit r10-9871-g799cf16051844f80d09526f17194373902254708 Author: Harald Anlauf Date: Mon May 17 21:35:38 2021 +0200 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. (cherry picked from commit 09867aa0ef7568012650395189b735f9a34cf9b5) Diff: --- gcc/fortran/trans-decl.c | 1 + gcc/testsuite/gfortran.dg/pr98411.f90 | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 529417fa8aa..bca15a51d99 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -737,6 +737,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