public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 37835 -fno-automatic does not work for derived types with default initalizer
@ 2019-01-18 17:43 Dominique d'Humières
  2019-01-19 15:50 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Dominique d'Humières @ 2019-01-18 17:43 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

Hi all!

The patch for gcc/fortran/resolve.c is the modernized version of Paul’s patch in comment 4.
It causes some regressions due to "Duplicate SAVE » warnings. 
They are silenced by the patch for gcc/fortran/symbol.c unless -pedantic is used as documented
in the change for gcc/fortran/invoke.texi.

Is it OK for trunk?

TIA

Dominique

2019-01-18  Dominique d'Humieres  <dominiq@gcc.gnu.org>

	PR fortran/37835
	* resolve.c (resolve_types): Add !flag_automatic.
	* symbol.c (gfc_add_save): Silence warnings.

2019-01-18  Dominique d'Humieres  <dominiq@gcc.gnu.org>

	PR fortran/37835
	* gfortran.dg/no-automatic.f90: New test.


[-- Attachment #2: patch-37835 --]
[-- Type: application/octet-stream, Size: 2076 bytes --]

diff -up ../_clean/gcc/fortran/resolve.c gcc/fortran/resolve.c
--- ../_clean/gcc/fortran/resolve.c	2019-01-15 23:24:11.000000000 +0100
+++ gcc/fortran/resolve.c	2019-01-17 11:45:32.000000000 +0100
@@ -16669,7 +16669,7 @@ resolve_types (gfc_namespace *ns)
 
   gfc_traverse_ns (ns, resolve_values);
 
-  if (ns->save_all)
+  if (ns->save_all || !flag_automatic)
     gfc_save_all (ns);
 
   iter_stack = NULL;
diff -up ../_clean/gcc/fortran/symbol.c gcc/fortran/symbol.c
--- ../_clean/gcc/fortran/symbol.c	2019-01-09 22:54:02.000000000 +0100
+++ gcc/fortran/symbol.c	2019-01-17 11:47:57.000000000 +0100
@@ -1306,7 +1306,8 @@ gfc_add_save (symbol_attribute *attr, sa
   if (s == SAVE_EXPLICIT)
     gfc_unset_implicit_pure (NULL);
 
-  if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT)
+  if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT
+      && (flag_automatic || pedantic))
     {
 	if (!gfc_notify_std (GFC_STD_LEGACY,
 			     "Duplicate SAVE attribute specified at %L",
--- ../_clean/gcc/testsuite/gfortran.dg/no-automatic.f90	1970-01-01 01:00:00.000000000 +0100
+++ gcc/testsuite/gfortran.dg/no-automatic.f90	2019-01-16 17:34:49.000000000 +0100
@@ -0,0 +1,20 @@
+! { dg-do run }
+! { dg-options "-fno-automatic" }
+!
+! PR fortran/37835
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>.
+!
+subroutine foo(n)
+  integer :: n
+  type t
+    integer :: i = 42
+  end type t
+  type(t) :: myt
+  if(n==1) myt%i = 2
+  print *, myt%i
+  if (n > 1 .and. myt%i /= 2) stop 1
+end subroutine foo
+
+call foo(1)
+call foo(2)
+end
--- ../_clean/gcc/fortran/invoke.texi	2019-01-09 22:54:02.000000000 +0100
+++ gcc/fortran/invoke.texi	2019-01-18 11:33:25.000000000 +0100
@@ -1377,6 +1377,9 @@ The default, which is @option{-fautomati
 variables smaller than the value given by @option{-fmax-stack-var-size}.
 Use the option @option{-frecursive} to use no static memory. 
 
+Local variables or arrays having an explicit @code{SAVE} attribute are
+silently ignored unless the @option{-pedantic} option is added.
+
 @item -ff2c
 @opindex ff2c
 @cindex calling convention

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 37835 -fno-automatic does not work for derived types with default initalizer
  2019-01-18 17:43 [Patch, Fortran] PR 37835 -fno-automatic does not work for derived types with default initalizer Dominique d'Humières
@ 2019-01-19 15:50 ` Thomas Koenig
  2019-01-19 21:56   ` Dominique d'Humières
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2019-01-19 15:50 UTC (permalink / raw)
  To: Dominique d'Humières, Paul Richard Thomas; +Cc: gfortran, gcc-patches

Hi Dominique,

> The patch for gcc/fortran/resolve.c is the modernized version of Paul’s patch in comment 4.
> It causes some regressions due to "Duplicate SAVE » warnings.
> They are silenced by the patch for gcc/fortran/symbol.c unless -pedantic is used as documented
> in the change for gcc/fortran/invoke.texi.
> 
> Is it OK for trunk?

I assume you did a regression test. OK if this has passed.

Thanks for the patch!

Regards

	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 37835 -fno-automatic does not work for derived types with default initalizer
  2019-01-19 15:50 ` Thomas Koenig
@ 2019-01-19 21:56   ` Dominique d'Humières
  0 siblings, 0 replies; 3+ messages in thread
From: Dominique d'Humières @ 2019-01-19 21:56 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: Paul Richard Thomas, gfortran, gcc-patches

Thanks for the review, committed as r268098.

Dominique

> Le 19 janv. 2019 à 16:50, Thomas Koenig <tkoenig@netcologne.de> a écrit :
> 
> Hi Dominique,
> 
>> The patch for gcc/fortran/resolve.c is the modernized version of Paul’s patch in comment 4.
>> It causes some regressions due to "Duplicate SAVE » warnings.
>> They are silenced by the patch for gcc/fortran/symbol.c unless -pedantic is used as documented
>> in the change for gcc/fortran/invoke.texi.
>> Is it OK for trunk?
> 
> I assume you did a regression test. OK if this has passed.

I have never submitted a patch without regtesting it!

> 
> Thanks for the patch!
> 
> Regards
> 
> 	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-19 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 17:43 [Patch, Fortran] PR 37835 -fno-automatic does not work for derived types with default initalizer Dominique d'Humières
2019-01-19 15:50 ` Thomas Koenig
2019-01-19 21:56   ` Dominique d'Humières

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).