On 04/10/2019 11:39, Jakub Jelinek wrote:
On Wed, Oct 02, 2019 at 03:31:53PM +0100, Mark Eggleston wrote:
It was there because the code base has -fno-automatic for procedures are
that aren't recursive and the -frecursive was used because the recursive
routines don't have the recursive keyword. (Legacy issues...). It is to
ensure that the use of -fno-automatic does not affect local variables in
recursive routine.
Ah, seems while -frecursive -fno-automatic emits a warning that can be read
that as if -frecursive is ignored, it just forces all (unless explicitly 
automatic)
variables to be saved, but still allows recursion.  One just has to manually
arrange for the variables that shouldn't be saved to be automatic.
So, I'm not against that test.
If a procedure is marked with the keyword recursive all its local variables
are always automatic by default. If a procedure is not marked with the
keyword recursive its variables are not automatic when -fno-automatic is
used unless they have the automatic attribute specified directly or acquired
via the equivalence statement, recursion can still be effected using
-frecursive provided all the variables used by the recursion are automatic.

+! { dg-warning "Flag '-fno-automatic' overwrites '-frecursive'" "warning" { 
target *-*-* } 0 }
I think you want one runtime test (e.g. the one you wrote in
automatics_in_equivalence_1.f90)
The errors checked there only check that automatic can be used that's
already covered by dec_static_3.f90 and automatic can't be used in
equivalence with the use of -fdec-static.
   and the rest just dg-do compile tests that
will check the original or gimple dumps to verify what happened in addition
to checking diagnostics (none) from the compilation, one testing the
default, another -fno-automatic, but in both cases without -frecursive.
Not sure what you mean, here. Are these already handled by the tests for
-fdec-static?
I meant add a couple of new tests.  One like:
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
! { dg-final { scan-tree-dump "static union" "original" } }

subroutine foo
   integer, save :: a, b
   equivalence (a, b)
   a = 5
   if (b.ne.5) stop 1
end subroutine

which verifies that the equivalence is saved in that case.  Another one
like:
! { dg-do compile }
! { dg-options "-fdec-static -fdump-tree-original -fno-automatic" }
! { dg-final { scan-tree-dump-not "static union" "original" } }

subroutine foo
   integer, automatic :: a
   integer :: b
   equivalence (a, b)
   a = 5
   if (b.ne.5) stop 1
end subroutine

another one perhaps with swapped ", automatic" between a and b.
Another two without the -fno-automatic?

        Jakub

Please find attached patch for additional test cases. Are these sufficient? If so, OK to commit?

Change log:

    Mark Eggleston <mark.eggles...@codethink.com>

    * gfortran.dg/auto_in_equiv_3.f90: New test.
    * gfortran.dg/auto_in_equiv_4.f90: New test.
    * gfortran.dg/auto_in_equiv_5.f90: New test.
    * gfortran.dg/auto_in_equiv_6.f90: New test.
    * gfortran.dg/auto_in_equiv_7.f90: New test.

--
https://www.codethink.co.uk/privacy.html

>From 55f816f614e22d2733b31d5e3a246caaa2809044 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggles...@codethink.com>
Date: Thu, 10 Oct 2019 15:01:11 +0100
Subject: [PATCH 1/2] New Automatics in equivalences test cases

---
 gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 | 19 +++++++++++++++++++
 gcc/testsuite/gfortran.dg/auto_in_equiv_4.f90 | 18 ++++++++++++++++++
 gcc/testsuite/gfortran.dg/auto_in_equiv_5.f90 | 18 ++++++++++++++++++
 gcc/testsuite/gfortran.dg/auto_in_equiv_6.f90 | 18 ++++++++++++++++++
 gcc/testsuite/gfortran.dg/auto_in_equiv_7.f90 | 19 +++++++++++++++++++
 5 files changed, 92 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_4.f90
 create mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_5.f90
 create mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_6.f90
 create mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_7.f90

diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90
new file mode 100644
index 00000000000..35f6e0fa27d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-fdec-static -fdump-tree-original" }
+!
+
+subroutine foo
+  integer, automatic :: a
+  integer :: b
+  equivalence (a, b)
+  a = 5
+  if (b.ne.5) stop 1
+end subroutine
+
+! { dg-final { scan-tree-dump "union" "original" } }
+! { dg-final { scan-tree-dump-not "static union" "original" } }
+! { dg-final { scan-tree-dump "integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump-not "static integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump "integer\\(kind=4\\) b" "original" } }
+! { dg-final { scan-tree-dump-not "static integer\\(kind=4\\) b" "original" } }
+
diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_4.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_4.f90
new file mode 100644
index 00000000000..508b3084ce3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_4.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fdec-static -fno-automatic -fdump-tree-original" }
+!
+! Neither of the local variable have the auotmatic attribute so they
+! not be allocated on the stack.
+
+subroutine foo
+  integer :: a
+  integer :: b
+  equivalence (a, b)
+  a = 5
+  if (b.ne.5) stop 1
+end subroutine
+
+! { dg-final { scan-tree-dump "static union" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) b" "original" } }
+
diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_5.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_5.f90
new file mode 100644
index 00000000000..bddf78d711c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_5.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Neither of the local variable have the auotmatic attribute so they
+! not be allocated on the stack.
+
+subroutine foo
+  integer, save :: a
+  integer :: b
+  equivalence (a, b)
+  a = 5
+  if (b.ne.5) stop 1
+end subroutine
+
+! { dg-final { scan-tree-dump "static union" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) b" "original" } }
+
diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_6.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_6.f90
new file mode 100644
index 00000000000..c0fc24e67a5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_6.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fdec-static -fdump-tree-original" }
+!
+! Neither of the local variable have the auotmatic attribute so they
+! not be allocated on the stack.
+
+subroutine foo
+  integer, static :: a
+  integer :: b
+  equivalence (a, b)
+  a = 5
+  if (b.ne.5) stop 1
+end subroutine
+
+! { dg-final { scan-tree-dump "static union" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump "static integer\\(kind=4\\) b" "original" } }
+
diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_7.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_7.f90
new file mode 100644
index 00000000000..fd7e6721383
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_7.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-fdec-static -fdump-tree-original" }
+!
+
+subroutine foo
+  integer :: a
+  integer, automatic :: b
+  equivalence (a, b)
+  a = 5
+  if (b.ne.5) stop 1
+end subroutine
+
+! { dg-final { scan-tree-dump "union" "original" } }
+! { dg-final { scan-tree-dump-not "static union" "original" } }
+! { dg-final { scan-tree-dump "integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump-not "static integer\\(kind=4\\) a" "original" } }
+! { dg-final { scan-tree-dump "integer\\(kind=4\\) b" "original" } }
+! { dg-final { scan-tree-dump-not "static integer\\(kind=4\\) b" "original" } }
+
-- 
2.11.0

Reply via email to