Dear all,
I would like to have some help about which DWARF a compiler should
generate for NAMELISTS which are USE associated with the ONLY clause.
For a namelist declared in a module (or in a procedure
[subroutine/function]) one generates a DW_TAG_namelist which contains a
list of DW_TAG_namelist_item (which are variables). (e.g.: "namelist
/nml_name/ var1, var2")
When one use-associates them without only ("USE m"), one can simply use:
DW_TAG_imported_module – and the compiler handles the access ("print
m::nml_name").
However, if one uses the ONLY clause ("use m, only: nml_name"), one
needs to create a DW_TAG_imported_declaration. In that case, the
DW_TAG_imported_declaration points to the DW_TAG_namelist, which one
needs to create.
And there is the problem: DW_TAG_namelist has a list of
DW_TAG_namelist_item, but in terms of the Fortran standard, only has
only use associated the namelist and not the variables which happen to
be in the namelist. As they are not use associated, the compiler won't
create a declaration (and no DW_TAG_variable) for them.
Question: Would it be permissible to create a
DW_TAG_imported_declaration for a DW_TAG_namelist with an empty
DW_TAG_namelist_item list and rely on the compiler to fetch the namelist
items from the module's DW_TAG_namelist?
If not and one has to fill the DW_TAG_namelist_item list: Shall one
create dummy "DW_TAG_variable"s for all those variables in the namelist?
If so, using which local name? (In terms of the Fortran language, they
aren't use-associated and thus aren't available.)
Example (assume two files):
module mm
integer :: ii
real :: rr
NAMELIST /nml/ ii, rr
end module mm
subroutine read_nml()
use mm, only: nml
read(99, nml=nml)
end subroutine read_nml
The program reads the namelist "nml" from the file associated with the
file ID 99. An example input would be:
&nml ii = 5, rr = 334.44 /
(As the namelist name appears in the input, namelists may not be renamed
in the USE statement.)
Tobias
PS: For cross-ref, the issue came up when writting a patch for
GCC/gfortran: http://gcc.gnu.org/ml/fortran/2013-11/msg00060.html
PPS: While gdb handles modules (both DW_TAG_imported_module and
DW_TAG_imported_declaration), it doesn't yet support DW_TAG_namelist
[gdb bug 15353]. And the other compilers I tried either didn't create a
DW_TAG_namelist or they didn't handled
DW_TAG_imported_module/DW_TAG_imported_declaration.
_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org