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

            Bug ID: 105454
           Summary: DWARF has wrong decl_line for type defined inside
                    program
           Product: gcc
           Version: 9.4.1
            Status: UNCONFIRMED
          Keywords: wrong-debug
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nils-christian.kempke at intel dot com
  Target Milestone: ---

This was tested with

-------------------------------------------------------------------
>> gfortran --version
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
-------------------------------------------------------------------

Compiling the following code

-------------------------------------------------------------------
>> cat test.f90
program MAIN

  type :: localtype
    integer :: a
  end type localtype

  type(localtype) :: var
  var%a = 1

  print *, var
end program
-------------------------------------------------------------------

via

-------------------------------------------------------------------
>> gfortran -O0 -g ./test.f90
-------------------------------------------------------------------

and looking at its DWARF output via objdump shows
-------------------------------------------------------------------
...
 <1><2e>: Abbrev Number: 2 (DW_TAG_structure_type)
    <2f>   DW_AT_name        : (indirect string, offset: 0x10): localtype
    <33>   DW_AT_byte_size   : 4
    <34>   DW_AT_decl_file   : 1
    <35>   DW_AT_decl_line   : 1
    <36>   DW_AT_sibling     : <0x45>
 <2><3a>: Abbrev Number: 3 (DW_TAG_member)
    <3b>   DW_AT_name        : a
    <3d>   DW_AT_decl_file   : 1
    <3e>   DW_AT_decl_line   : 4
    <3f>   DW_AT_type        : <0x45>
    <43>   DW_AT_data_member_location: 0
 <2><44>: Abbrev Number: 0
...
-------------------------------------------------------------------

Note, that localtype has a DW_AT_decl_line 1 while in the actual source file it
is line 3. Its member a however has correct source code correlation as it is,
in fact, introduced on line 4.

Correctly, gfortran should place the localtype on line 3, the first line for
the declared type.

Reply via email to