flang-compiler / f18

F18 is a front-end for Fortran intended to replace the existing front-end in the Flang compiler
229 stars 48 forks source link

Allow for access-stmt before namelist-stmt #1023

Closed tskeith closed 4 years ago

tskeith commented 4 years ago

You can declare a name in an access statement and then declare it as a namelist group name. We weren't allowing that because we didn't convert a symbol with UnknownDetails to one with NamelistDetails.

Fixes #1022.

vjayathirtha-nv commented 4 years ago

I tried the test case @klausler suggested.

module m
  integer, private :: x
  public :: INLIST
  NAMELIST /INLIST/ x
  integer :: INLIST
end module m

Here's the error I see

/home/vjayath/nml4.f90:5:14: error: 'nlist' is already declared in this scoping unit
    integer :: NLIST
               ^^^^^
/home/vjayath/nml4.f90:3:13: Previous declaration of 'nlist'
    public :: NLIST
              ^^^^^
f18: semantic errors in /home/vjayath/nml4.f90

Should the info message be pointing to line no. 4 instead of 3? If a programmer has no idea the NLIST namelist has been declared, having an access statement seems perfectly legal.

Apart from that, the change looks good to me.

tskeith commented 4 years ago

I tried the test case @klausler suggested.

module m
  integer, private :: x
  public :: INLIST
  NAMELIST /INLIST/ x
  integer :: INLIST
end module m

Here's the error I see

/home/vjayath/nml4.f90:5:14: error: 'nlist' is already declared in this scoping unit
    integer :: NLIST
               ^^^^^
/home/vjayath/nml4.f90:3:13: Previous declaration of 'nlist'
    public :: NLIST
              ^^^^^
f18: semantic errors in /home/vjayath/nml4.f90

Should the info message be pointing to line no. 4 instead of 3? If a programmer has no idea the NLIST namelist has been declared, having an access statement seems perfectly legal.

I've fixed it so that the name of the symbol is the occurrence of "NLIST" at line 4.