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/95446] False positive for optional arguments of elemental procedure
Date: Sun, 31 May 2020 04:02:23 +0000	[thread overview]
Message-ID: <bug-95446-4-gZF29NM5kC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95446-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

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

--- Comment #1 from kargl at gcc dot gnu.org ---
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 280157)
+++ gcc/fortran/resolve.c       (working copy)
@@ -2275,11 +2275,27 @@ resolve_elemental_actual (gfc_expr *expr, gfc_code *c)
          && (set_by_optional || arg->expr->rank != rank)
          && !(isym && isym->id == GFC_ISYM_CONVERSION))
        {
-         gfc_warning (OPT_Wpedantic,
-                      "%qs at %L is an array and OPTIONAL; IF IT IS "
-                      "MISSING, it cannot be the actual argument of an "
-                      "ELEMENTAL procedure unless there is a non-optional "
-                      "argument with the same rank (12.4.1.5)",
+          bool t = false;
+          gfc_actual_arglist *a;
+
+         /* Scan the argument list for a non-optional argument with the
+            same rank as arg.  */
+          for (a = arg0; a; a = a->next)
+            if (a != arg
+               && a->expr->rank == arg->expr->rank
+               && !a->expr->symtree->n.sym->attr.optional)
+             {
+               t = true;
+               break;
+             }
+          
+         if (!t)
+           gfc_warning (OPT_Wpedantic,
+                      "%qs at %L is an array with an OPTIONAL attribute; "
+                      "If it is not present, than it cannot be the actual "
+                      "argument of an ELEMENTAL procedure unless there is "
+                      "a non-optional argument with the same rank "
+                      "(Fortran 2018, 15.5.2.12)",
                       arg->expr->symtree->n.sym->name, &arg->expr->where);
        }
     }

  reply	other threads:[~2020-05-31  4:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-30 22:45 [Bug fortran/95446] New: " m.diehl at mpie dot de
2020-05-31  4:02 ` kargl at gcc dot gnu.org [this message]
2020-05-31  7:13 ` [Bug fortran/95446] " m.diehl at mpie dot de
2020-06-09 10:48 ` dominiq at lps dot ens.fr
2020-07-01 14:40 ` cvs-commit at gcc dot gnu.org
2020-07-02  7:24 ` markeggleston at gcc dot gnu.org

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-95446-4-gZF29NM5kC@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).