[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-21 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

Jerry DeLisle  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #7 from Jerry DeLisle  ---
Fixed on trunk.

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

--- Comment #6 from CVS Commits  ---
The master branch has been updated by Jerry DeLisle :

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

commit r11-7306-gdfa2f821c18b7e926b5f5d6e394a0c915937db5e
Author: Jerry DeLisle 
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.

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-15 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

--- Comment #5 from Jerry DeLisle  ---
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.

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-14 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

--- Comment #4 from Jerry DeLisle  ---
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 (>attr, sym->name, NULL))
goto error;

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

--- Comment #3 from Jerry DeLisle  ---
I am changing the word 'defined' to 'declared'.

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-02-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

Jerry DeLisle  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  ---
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?

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-01-19 Thread dominiq at lps dot ens.fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98686

Dominique d'Humieres  changed:

   What|Removed |Added

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

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-01-14 Thread anlauf at gcc dot gnu.org via 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.

[Bug fortran/98686] Namelist group objects shall be defined before appearing in namelist for -std=f2018

2021-01-14 Thread anlauf at gcc dot gnu.org via 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