[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-21 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #18 from anlauf at gcc dot gnu.org ---
Fixed on all affected branches.  Closing.

Thanks for the report!

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-21 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #17 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:d3db5b1d23cbe4e4569e688a6dbc8b5b2c38588e

commit r10-10140-gd3db5b1d23cbe4e4569e688a6dbc8b5b2c38588e
Author: Harald Anlauf 
Date:   Fri Sep 17 21:45:33 2021 +0200

Fortran - (large) arrays in the main shall be static

gcc/fortran/ChangeLog:

PR fortran/102366
* trans-decl.c (gfc_finish_var_decl): Disable the warning message
for variables moved from stack to static storange if they are
declared in the main, but allow the move to happen.

gcc/testsuite/ChangeLog:

PR fortran/102366
* gfortran.dg/pr102366.f90: New test.

(cherry picked from commit 51166eb2c534692c3c7779def24f83c8c3811b98)

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-21 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #16 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:7fbab3afca910c055676ebc566bf87c4d5a7372f

commit r11-9020-g7fbab3afca910c055676ebc566bf87c4d5a7372f
Author: Harald Anlauf 
Date:   Fri Sep 17 21:45:33 2021 +0200

Fortran - (large) arrays in the main shall be static

gcc/fortran/ChangeLog:

PR fortran/102366
* trans-decl.c (gfc_finish_var_decl): Disable the warning message
for variables moved from stack to static storange if they are
declared in the main, but allow the move to happen.

gcc/testsuite/ChangeLog:

PR fortran/102366
* gfortran.dg/pr102366.f90: New test.

(cherry picked from commit 51166eb2c534692c3c7779def24f83c8c3811b98)

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org

--- Comment #15 from anlauf at gcc dot gnu.org ---
Committed as per Jakub's LGTM and announced here:

https://gcc.gnu.org/pipermail/fortran/2021-September/056540.html

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #14 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:51166eb2c534692c3c7779def24f83c8c3811b98

commit r12-3639-g51166eb2c534692c3c7779def24f83c8c3811b98
Author: Harald Anlauf 
Date:   Fri Sep 17 21:45:33 2021 +0200

Fortran - (large) arrays in the main shall be static

gcc/fortran/ChangeLog:

PR fortran/102366
* trans-decl.c (gfc_finish_var_decl): Disable the warning message
for variables moved from stack to static storange if they are
declared in the main, but allow the move to happen.

gcc/testsuite/ChangeLog:

PR fortran/102366
* gfortran.dg/pr102366.f90: New test.

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #13 from anlauf at gcc dot gnu.org ---
In decl.c:match_attr_spec we have:

5818  /* Since Fortran 2008 module variables implicitly have the SAVE
attribute.  */
5819  if ((gfc_current_state () == COMP_MODULE
5820   || gfc_current_state () == COMP_SUBMODULE)
5821  && !current_attr.save
5822  && (gfc_option.allow_std & GFC_STD_F2008) != 0)
5823current_attr.save = SAVE_IMPLICIT;

I tried to extend that to the case of COMP_PROGRAM, but:

(gdb) p gfc_state_stack->state 
$162 = COMP_NONE

But when I add

program test

at the beginning of the file, I find

(gdb) p gfc_state_stack->state 
$164 = COMP_PROGRAM

So this may be too early to handle arrays in the main.

Given Jakub's comment, I'll fix that and regtest.

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #12 from Jakub Jelinek  ---
That LGTM, except formatting - && shouldn't be at the end of line per coding
conventions, but on the start of next line.

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #11 from anlauf at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #10)

> The problem is gone if I revert r12-3129.

But then it regresses on pr98411.  See for yourself compiling with -Wall.

Something like

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index bed61e2325d..b022d818e82 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -743,7 +743,6 @@ 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
@@ -757,7 +756,9 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
  || sym->attr.allocatable)
   && !DECL_ARTIFICIAL (decl))
 {
-  if (flag_max_stack_var_size > 0)
+  if (flag_max_stack_var_size > 0
+ && !(sym->ns->proc_name &&
+  sym->ns->proc_name->attr.is_main_program))
gfc_warning (OPT_Wsurprising,
 "Array %qs at %L is larger than limit set by "
 "%<-fmax-stack-var-size=%>, moved from stack to static "

disables the warning for arrays in the main.

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-17 Thread dominiq at lps dot ens.fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #10 from Dominique d'Humieres  ---
> Seems it changed with r12-3129-gf95946afd160e2a1f4beac4ee5e6d5633307f39a

The problem is gone if I revert r12-3129.

[Bug fortran/102366] [10/11/12 Regression] large arrays no longer become static

2021-09-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

Andrew Pinski  changed:

   What|Removed |Added

Summary|[10/11/12 Regression]   |[10/11/12 Regression] large
   |Illegal instruction with|arrays no longer become
   |large arrays|static
   Target Milestone|--- |10.4