public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
Date: Sun, 14 Feb 2021 19:27:14 +0000	[thread overview]
Message-ID: <bug-98686-4-aUViBnKbHL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98686-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
One of this difficulties here is:

"If a namelist group object is typed by the implicit typing rules, its
appearance in any subsequent type declaration statement shall confirm the
implied type and type parameters."

If one takes away the IMPLICIT NONE in the example given, it would be valid
only if the subsequent explicit declarations agreed with the IMPLICIT.  As far
as I know, there is no checking that explicit declarations confirm IMPLICIT.

My thinking is to add the check I have so far and defer the confirmatory checks
elsewhere, maybe as a warning. Otherwise I think it is can of worms.  I do
think it might be useful to warn people about not confirming an implicit type
since it is conceivable that someone might contradict themselves while
modifying legacy codes.  This is why we always recommend IMPLICIT NONE
regardless.

The patch at this point regressions tests OK.

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 2df6191d7e6..2e6d1db515a 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -5536,6 +5536,17 @@ gfc_match_namelist (void)
          if (m == MATCH_ERROR)
            goto error;

+         /* It is required that members of a namelist be declared
+            before the namelist.  We check this by checking if the
+            symbol has a defined type.  */
+         if (gfc_current_ns->seen_implicit_none &&
+             sym->ts.type == BT_UNKNOWN)
+           {
+             gfc_error ("Symbol %qs in namelist %qs at %C must be "
+                        "declared before the namelist is declared.",
+                        sym->name, group_name->name);
+             goto error;
+           }
          if (sym->attr.in_namelist == 0
              && !gfc_add_in_namelist (&sym->attr, sym->name, NULL))
            goto error;

  parent reply	other threads:[~2021-02-14 19:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 17:10 [Bug fortran/98686] New: " anlauf at gcc dot gnu.org
2021-01-14 17:11 ` [Bug fortran/98686] " anlauf at gcc dot gnu.org
2021-01-14 18:05 ` anlauf at gcc dot gnu.org
2021-01-19  9:53 ` dominiq at lps dot ens.fr
2021-02-14  1:53 ` jvdelisle at gcc dot gnu.org
2021-02-14  2:43 ` jvdelisle at gcc dot gnu.org
2021-02-14 19:27 ` jvdelisle at gcc dot gnu.org [this message]
2021-02-15 20:17 ` jvdelisle at gcc dot gnu.org
2021-02-19 20:48 ` cvs-commit at gcc dot gnu.org
2021-02-22  4:27 ` jvdelisle 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-98686-4-aUViBnKbHL@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).