public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix
Date: Tue, 15 Sep 2020 22:35:41 +0200	[thread overview]
Message-ID: <trinity-2e95f245-4651-47b4-87f5-6c96204fe540-1600202141362@3c-app-gmx-bap13> (raw)

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

As stated in the PR, the Fortran 2018 standard removed the restriction
prohibiting ELEMENTAL RECURSIVE procedures.  Adjust the relevant check.

Regtested on x86_64-pc-linux-gnu.

OK for master?

Thanks,
Harald


PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix

gcc/fortran/ChangeLog:

	* symbol.c (gfc_check_conflict): Allow ELEMENTAL RECURSIVE
	procedure prefix for -std=f2018.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr97036.f90: New test.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr97036.patch --]
[-- Type: text/x-patch, Size: 1470 bytes --]

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index abd3b5ccfd0..df1e8965daa 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -569,7 +569,7 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where)
   conf_std (allocatable, dummy, GFC_STD_F2003);
   conf_std (allocatable, function, GFC_STD_F2003);
   conf_std (allocatable, result, GFC_STD_F2003);
-  conf (elemental, recursive);
+  conf_std (elemental, recursive, GFC_STD_F2018);

   conf (in_common, dummy);
   conf (in_common, allocatable);
diff --git a/gcc/testsuite/gfortran.dg/pr97036.f90 b/gcc/testsuite/gfortran.dg/pr97036.f90
new file mode 100644
index 00000000000..cfe51debce1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr97036.f90
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+! PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix
+
+module m97036
+  implicit none
+contains
+  impure elemental recursive subroutine foo (n)
+    integer, intent(in) :: n
+    integer :: k(n), f(n), i
+    k = [ (i-1, i=1,n) ]
+    f = fac (k)
+    print *, f
+  end subroutine foo
+  elemental recursive subroutine bla ()
+  end subroutine bla
+  elemental recursive function fac (k) result (f)
+    integer, intent(in) :: k
+    integer             :: f
+    f = 1
+    if (k > 1) f = k*fac (k-1)
+  end function fac
+end module
+  use m97036
+  implicit none
+  call foo ([4,5])
+end

             reply	other threads:[~2020-09-15 20:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 20:35 Harald Anlauf [this message]
2020-09-18 22:14 ` Jerry DeLisle

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=trinity-2e95f245-4651-47b4-87f5-6c96204fe540-1600202141362@3c-app-gmx-bap13 \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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: link
Be 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).