Issue 090321.1: DW_AT_declaration inheritance by DW_AT_specification

Author: Jan Kratochvil
Champion: John Bishop
Date submitted: 2009-03-21
Date revised:
Date closed:
Type: Ambiguity
Status: Accepted with modifications
DWARF Version: 4
Currently both GCC and GDB do not generate/assume inheritance of
DW_AT_declaration through DW_AT_specification.  It was discussed at:
http://sourceware.org/ml/gdb-patches/2004-04/threads.html#00296

And it is implemented in GDB by die_is_declaration():
http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/dwarf2read.c?cvsroot=src

But the DWARF spec says:
*Debugging information entries with a DW_AT_specification
  attribute do not need to duplicate information provided by the
  debugging information entry referenced by that specification
  attribute.*

Therefore the DIE completing former non-defining DIE should override 
its DW_AT_declaration by explicit DW_AT_declaration=0 to have its meaning
currently read by GDB.

Current DIEs:
 <3><247>: Abbrev Number: 18 (DW_TAG_variable)
    <248>   DW_AT_name        : cX
    <24b>   DW_AT_decl_file   : 1
    <24c>   DW_AT_decl_line   : 109
    <24d>   DW_AT_type        : <0xca>
    <251>   DW_AT_declaration : 1

 <1><5c5>: Abbrev Number: 37 (DW_TAG_variable)
    <5c6>   DW_AT_specification: <0x247>
    <5ca>   DW_AT_const_value : 6

IMO according to the current DWARF spec there is missing:
    <5cb>   DW_AT_declaration : 0

That DW_AT_declaration is not being inherited through DW_AT_specification
may be implied by the DWARF specification but it is not clear enough to me.

Please update the DWARF standard to say it explicitely:
*DW_AT_declaration and DW_AT_sibling attributes are not being
  inherited from the debugging information entry referenced by
  the specification attribute.*

---

Accepted with modifications. 

Add following text 2.13.2:
 
    *It is not the case that all the attributes of the debugging information entry
    referenced by a DW_AT_specification attribute apply to the referring debugging
    information entry.*