public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018
@ 2021-01-14 17:10 anlauf at gcc dot gnu.org
  2021-01-14 17:11 ` [Bug fortran/98686] " anlauf at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-01-14 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98686
           Summary: Namelist group objects shall be defined before
                    appearing in namelist for -std=f2018
           Product: gcc
           Version: fortran-dev
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

The following code is silently accepted even with -std=f95 ... -std=2018:

  implicit none
  namelist /NML/ x, m, q
  real    :: x, m
  integer :: q
  x = 1.0
  m = 2.0
  q = 3
  write(*, nml=NML)
end

It is properly rejected by NAG, and leads to fun with ifort, depending on
the -stand setting.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
@ 2021-01-14 17:11 ` anlauf at gcc dot gnu.org
  2021-01-14 18:05 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-01-14 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Priority|P3                          |P4
            Version|fortran-dev                 |11.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-01-14 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from anlauf at gcc dot gnu.org ---
F2018:

8.9  NAMELIST statement

(5) A namelist group object shall either be accessed by use or host association
or shall have its declared type, kind type parameters of the declared type, and
rank specified by previous specification statements or the procedure heading in
the same scoping unit or by the implicit typing rules in effect for the scoping
unit. 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-01-19  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-01-19

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-02-14  1:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I have this working:

pr98686.f90:2:19:

    2 |   namelist /NML/ x, m, q
      |                   1
Error: Symbol ‘x’ in namelist ‘nml’ at (1) must be defined before the namelist
is declared.

Does this read OK?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-02-14  2:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I am changing the word 'defined' to 'declared'.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-02-14  2:43 ` jvdelisle at gcc dot gnu.org
@ 2021-02-14 19:27 ` jvdelisle at gcc dot gnu.org
  2021-02-15 20:17 ` jvdelisle at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-02-14 19:27 UTC (permalink / raw)
  To: gcc-bugs

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;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-02-14 19:27 ` jvdelisle at gcc dot gnu.org
@ 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
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-02-15 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
The wording in the F2018 standard goes all the way back to F95. I do not plan
to put this behind any check for any particular standard.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-19 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:dfa2f821c18b7e926b5f5d6e394a0c915937db5e

commit r11-7306-gdfa2f821c18b7e926b5f5d6e394a0c915937db5e
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Fri Feb 19 12:47:54 2021 -0800

    fortran: Object types should be declared before use in NAMELIST.

    gcc/fortran/ChangeLog:

            PR fortran/98686
            * match.c (gfc_match_namelist): If BT_UNKNOWN, check for
            IMPLICIT NONE and and issue an error, otherwise set the type
            to its IMPLICIT type so that any subsequent use of objects will
            will confirm their types.

    gcc/testsuite/ChangeLog:

            PR fortran/98686
            * gfortran.dg/namelist_4.f90: Modify.
            * gfortran.dg/namelist_98.f90: New test.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018
  2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 anlauf at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-02-19 20:48 ` cvs-commit at gcc dot gnu.org
@ 2021-02-22  4:27 ` jvdelisle at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-02-22  4:27 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Fixed on trunk.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-22  4:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 17:10 [Bug fortran/98686] New: Namelist group objects shall be defined before appearing in namelist for -std=f2018 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
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

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).