public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/78219] [F08] specifying the kind of a FORALL index in the header
Date: Wed, 21 Jul 2021 00:17:52 +0000	[thread overview]
Message-ID: <bug-78219-4-SjcqvmgSDG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-78219-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78219

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #7 from kargl at gcc dot gnu.org ---
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index d148de3e3b5..d7668f6a928 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2350,6 +2350,34 @@ match_forall_iterator (gfc_forall_iterator **result)
   gfc_forall_iterator *iter;
   locus where;
   match m;
+  gfc_typespec ts;
+  bool seen_ts;
+
+  /* In Fortran 2018, one can do "forall (integer :: i = 1:20)".
+     Try to match an optional "type-spec ::"  */
+  seen_ts = false;
+  gfc_clear_ts (&ts);
+  m = gfc_match_type_spec (&ts);
+  if (m == MATCH_YES)
+    {
+      seen_ts = (gfc_match (" ::") == MATCH_YES);
+
+      if (seen_ts)
+       {
+         if (!gfc_notify_std (GFC_STD_F2018, "FORALL includes a "
+                              "type specification at %C"))
+           return MATCH_ERROR;
+
+         if (ts.type != BT_INTEGER)
+           {
+             gfc_error ("Type-spec at %L shall be INTEGER",
+                        &gfc_current_locus);
+             return MATCH_ERROR;
+           }
+       }
+    }
+  else if (m == MATCH_ERROR)
+    return m;

   where = gfc_current_locus;
   iter = XCNEW (gfc_forall_iterator);
@@ -2358,6 +2386,9 @@ match_forall_iterator (gfc_forall_iterator **result)
   if (m != MATCH_YES)
     goto cleanup;

+  if (seen_ts)
+    iter->var->ts = ts;
+
   if (gfc_match_char ('=') != MATCH_YES
       || iter->var->expr_type != EXPR_VARIABLE)
     {

       reply	other threads:[~2021-07-21  0:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-78219-4@http.gcc.gnu.org/bugzilla/>
2021-07-21  0:17 ` kargl at gcc dot gnu.org [this message]
2021-07-21 22:09 ` kargl at gcc dot gnu.org
2021-09-21 20:01 ` anlauf at gcc dot gnu.org
2021-09-21 20:05 ` anlauf at gcc dot gnu.org
2021-11-01 21:40 ` kargl at gcc dot gnu.org
2024-04-04 19:57 ` longb at cray dot com

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=bug-78219-4-SjcqvmgSDG@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).