Issue 180517.1: Variant parts without a discriminant

Author: Tom Tromey
Champion: Jini Susan George
Date submitted: 2018-05-17
Date revised:
Date closed: 2022-04-04
Type: Clarification
Status: Accepted with modifications
DWARF Version: 6
Section 5.7.10, pg 123


I worked recently on adding variant part DWARF output to the Rust 
compiler and LLVM.  While doing so I found this text in 5.7.10:

If the variant part does not have a discriminant (tag field), the 
variant part entry has a DW_AT_type attribute to represent the tag type.

I did not know how to interpret this.  I searched and found a dwarf-discuss 
thread touching on this topic, in particular this message:

http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2006-August/003088.html

.. which unfortunately merely expresses the same confusion that I have.


I suggest simply removing this paragraph from the standard.

Rust needs tagless variants, but I will file a separate issue for that.


DISCUSSION

The issue here is wrt the proposed removal of the potentially confusing 
following lines (Section 5.7.10, pg 123, lines 10-11):

If the variant part does not have a discriminant (tag field),  the variant
part entry has a DW_AT_type attribute to represent the tag type.

Since this line holds good in the Pascal context, the proposal to remove 
this line is rejected and instead, the following non-normative text can 
be added to provide additional clarification.


PROPOSED CHANGES

Append the following non-normative text:

*A reference to a type supports the Pascal notion of a tagless variant
part where the omitted tag nonetheless is given a type whose values are 
used in later parts of the variant syntax.*

--
2022-04-04:  Accepted with modifications
  In Section 5.7.10, change "has" to "may have":
  If the variant part does not have a discriminant (tag field), the variant
  part entry may have a DW_AT_type attribute to represent the tag type.