Patch for setting DW_AT_const_value in identity declaration VAR_DECLs

Jose E. Marchesi jemarch@gnu.org
Tue Sep 22 12:55:32 GMT 2026


> Hi Cupertino,
>
> On Tue, 2026-09-22 at 11:08 +0100, Cupertino Miranda wrote:
>> Thanks for looking into this patch. ;)
>> I guess we were not aware that was actually the use for the 
>> DW_AT_const_value.
>> 
>> What we will need is to be able to distinguish in GDB from a68 variables 
>> (var) and identity declarations (ide).
>> Identity declarations are constant values, but they might not get the 
>> constant in the beginning of block but instead at their first modify 
>> expression.
>> At least for that reason they are not traditional C like constants.
>> 
>> Is there any other way in DWARF to flag a DW_TAG_variable such that we 
>> would be able to distinguish between "var" and "ide"?
>> Is DW_TAG_constant Ok for this?
>
> I am not 100% sure, but I believe DW_TAG_constant is the right thing
> for this. Ada, D and Fortran use it for CONST_DECL. See gen_decl_die
> and gen_const_die in dwarf2out.cc. But I understand you are not using
> CONST_DECL for "identity declarations", so they might not be similar to
> the Ada, D and Fortran cases.

We cannot use CONST_DECL because:

1. We need to be able to MODIFY_EXPR them (see other email) and,
2. AFAIK CONST_DECL only works for GENERIC plain types like integers.

So I guess we might need to add a new langhook for dwarf2out to decide
for which VAR_DECLs a DW_AT_const_value shall be generated rather than a
DW_AT_variable.

The DW_AT_const_value can be of any type right?


More information about the Algol68 mailing list