public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10071] Fortran: fix pointless warning for static variables Date: Thu, 26 Aug 2021 18:52:01 +0000 (GMT) [thread overview] Message-ID: <20210826185201.D0D523858D3C@sourceware.org> (raw) https://gcc.gnu.org/g:d9887f6d99fe435dd63e1c0eefa820b24c7f4100 commit r10-10071-gd9887f6d99fe435dd63e1c0eefa820b24c7f4100 Author: Harald Anlauf <anlauf@gmx.de> Date: Tue Aug 24 21:07:50 2021 +0200 Fortran: fix pointless warning for static variables gcc/fortran/ChangeLog: PR fortran/98411 * trans-decl.c (gfc_finish_var_decl): Adjust check to handle implicit SAVE as well as variables in the main program. Improve warning message text. gcc/testsuite/ChangeLog: PR fortran/98411 * gfortran.dg/pr98411.f90: Adjust testcase options to restrict to F2008, and verify case of implicit SAVE. (cherry picked from commit f95946afd160e2a1f4beac4ee5e6d5633307f39a) Diff: --- gcc/fortran/trans-decl.c | 20 +++++++++++++------- gcc/testsuite/gfortran.dg/pr98411.f90 | 4 +++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index bca15a51d99..27b4a9bc73d 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -736,8 +736,10 @@ 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->ns->proc_name && sym->ns->proc_name->attr.is_main_program) && !sym->attr.automatic && sym->attr.save != SAVE_EXPLICIT + && sym->attr.save != SAVE_IMPLICIT && 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. */ @@ -750,13 +752,17 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) { if (flag_max_stack_var_size > 0) gfc_warning (OPT_Wsurprising, - "Array %qs at %L is larger than limit set by" - " %<-fmax-stack-var-size=%>, moved from stack to static" - " storage. This makes the procedure unsafe when called" - " recursively, or concurrently from multiple threads." - " Consider using %<-frecursive%>, or increase the" - " %<-fmax-stack-var-size=%> limit, or change the code to" - " use an ALLOCATABLE array.", + "Array %qs at %L is larger than limit set by " + "%<-fmax-stack-var-size=%>, moved from stack to static " + "storage. This makes the procedure unsafe when called " + "recursively, or concurrently from multiple threads. " + "Consider increasing the %<-fmax-stack-var-size=%> " + "limit (or use %<-frecursive%>, which implies " + "unlimited %<-fmax-stack-var-size%>) - or change the " + "code to use an ALLOCATABLE array. If the variable is " + "never accessed concurrently, this warning can be " + "ignored, and the variable could also be declared with " + "the SAVE attribute.", sym->name, &sym->declared_at); TREE_STATIC (decl) = 1; diff --git a/gcc/testsuite/gfortran.dg/pr98411.f90 b/gcc/testsuite/gfortran.dg/pr98411.f90 index 249afaea419..7c906a96f60 100644 --- a/gcc/testsuite/gfortran.dg/pr98411.f90 +++ b/gcc/testsuite/gfortran.dg/pr98411.f90 @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-Wall -fautomatic -fmax-stack-var-size=100" } +! { dg-options "-std=f2008 -Wall -fautomatic -fmax-stack-var-size=100" } ! PR fortran/98411 - Pointless warning for static variables module try @@ -9,8 +9,10 @@ contains subroutine initmodule real, save :: b(1000) logical :: c(1000) ! { dg-warning "moved from stack to static storage" } + integer :: e(1000) = 1 a(1) = 42 b(2) = 3.14 c(3) = .true. + e(5) = -1 end subroutine initmodule end module try
reply other threads:[~2021-08-26 18:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210826185201.D0D523858D3C@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).