[PATCH] a68: set names for the DWARF base types
Cupertino Miranda
cupertinomiranda@gmail.com
Fri Sep 25 21:02:20 GMT 2026
On 9/25/26 7:32 PM, Jose E. Marchesi wrote:
>
> Hi Cuper.
> Thanks for the patch.
>
>> DWARF output contained no names for the compiler's base types, so
>> they were emitted with the type name __unknown__. In dwarf2out.cc,
>> comments suggest that the __unknown__ type code flow is likely a bug.
>> a68 frontend never assigned names to its built-in types.
>>
>> This patch sets a type name for every built-in type during a68
>> initialization so they are emitted correctly in DWARF output.
>>
>> Signed-off-by: Cupertino Miranda <cupertinomiranda@gmail.com>
>>
>> gcc/algol68/ChangeLog
>>
>> * a68-lang.cc (PUSH_TYPE): Macro definition
>> (a68_build_a68_type_nodes): Inserted type names using
>> PUSH_TYPE macro.
>> (pushdecl): Added logic to insert name to the type
>> declaration.
>> ---
>> gcc/algol68/a68-lang.cc | 34 ++++++++++++++++++++++++++++++++++
>> 1 file changed, 34 insertions(+)
>>
>> diff --git a/gcc/algol68/a68-lang.cc b/gcc/algol68/a68-lang.cc
>> index 1cefb08c5ab..192e396fb49 100644
>> --- a/gcc/algol68/a68-lang.cc
>> +++ b/gcc/algol68/a68-lang.cc
>> @@ -123,6 +123,13 @@ a68_type_moid (tree type)
>> return TYPE_LANG_SPECIFIC (type)->moid;
>> }
>>
>> +/* Prototyped to avoid a major reordering of the function definitions. */
>> +static tree pushdecl (tree decl);
>> +
>> +#define PUSH_TYPE(name, node) \
>> + pushdecl (build_decl (input_location, \
>> + TYPE_DECL, get_identifier (name), node))
>> +
>
> If you want to call pushdecl in a68_build_a68_type_nodes, you will have
> to call a68_init_ranges before it in a68_init.
>
> Also, I would do the binding `TYPE_NAME (type) = decl' in the PUSH_TYPE
> macro, not in the pushdecl lang hook.
Are the globals initialized in a68_init_ranges the same as the one used
in a68_build_a68_type_nodes?
I think they are different and the get_global_context() in pushdecl
actually initializes the value if uninitialized.
Is there other more obscure reason why you said this?
>
>> /* Build the type trees in a68_global_trees. */
>>
>> static void
>> @@ -138,9 +145,11 @@ a68_build_a68_type_nodes (void)
>>
>> /* BOOL */
>> a68_bool_type = boolean_type_node;
>> + PUSH_TYPE ("BOOL", a68_bool_type);
>
> Nice, this seems to be a good way for doing this, provided the above.
>
>>
>> /* CHAR */
>> a68_char_type = uint32_type_node;
>> + PUSH_TYPE ("CHAR", a68_char_type);
>>
>> /* SHORT SHORT INT
>> SHORT INT
>> @@ -148,6 +157,9 @@ a68_build_a68_type_nodes (void)
>> a68_short_short_int_type = signed_char_type_node;
>> a68_short_int_type = short_integer_type_node;
>> a68_int_type = integer_type_node;
>> + PUSH_TYPE ("SHORT SHORT INT", a68_short_short_int_type);
>> + PUSH_TYPE ("SHORT INT", a68_short_int_type);
>> + PUSH_TYPE ("INT", a68_int_type);
>>
>> /* LONG INT */
>> if (int_size_in_bytes (long_integer_type_node)
>> @@ -158,6 +170,7 @@ a68_build_a68_type_nodes (void)
>> a68_long_int_type = long_long_integer_type_node;
>> else
>> a68_long_int_type = a68_int_type;
>> + PUSH_TYPE ("LONG INT", a68_long_int_type);
>>
>> /* LONG LONG INT */
>> if (int_size_in_bytes (long_integer_type_node)
>> @@ -168,6 +181,7 @@ a68_build_a68_type_nodes (void)
>> a68_long_long_int_type = long_long_integer_type_node;
>> else
>> a68_long_long_int_type = a68_long_int_type;
>> + PUSH_TYPE ("LONG LONG INT", a68_long_long_int_type);
>>
>> /* SHORT SHORT BITS
>> SHORT BITS
>> @@ -175,6 +189,9 @@ a68_build_a68_type_nodes (void)
>> a68_short_short_bits_type = unsigned_char_type_node;
>> a68_short_bits_type = short_unsigned_type_node;
>> a68_bits_type = unsigned_type_node;
>> + PUSH_TYPE ("SHORT SHORT BITS", a68_short_short_bits_type);
>> + PUSH_TYPE ("SHORT BITS", a68_short_bits_type);
>> + PUSH_TYPE ("BITS", a68_bits_type);
>>
>> /* LONG BITS */
>> if (int_size_in_bytes (long_unsigned_type_node)
>> @@ -185,6 +202,7 @@ a68_build_a68_type_nodes (void)
>> a68_long_bits_type = long_long_unsigned_type_node;
>> else
>> a68_long_bits_type = a68_bits_type;
>> + PUSH_TYPE ("LONG BITS", a68_long_bits_type);
>>
>> /* LONG LONG BITS */
>> if (int_size_in_bytes (long_unsigned_type_node)
>> @@ -195,11 +213,14 @@ a68_build_a68_type_nodes (void)
>> a68_long_long_bits_type = long_long_unsigned_type_node;
>> else
>> a68_long_long_bits_type = a68_long_bits_type;
>> + PUSH_TYPE ("LONG LONG BITS", a68_long_long_bits_type);
>>
>> /* BYTES
>> LONG BYTES */
>> a68_bytes_type = unsigned_type_node;
>> a68_long_bytes_type = long_unsigned_type_node;
>> + PUSH_TYPE ("BYTES", a68_bytes_type);
>> + PUSH_TYPE ("LONG BYTES", a68_long_bytes_type);
>>
>> /* REAL
>> LONG REAL
>> @@ -207,6 +228,9 @@ a68_build_a68_type_nodes (void)
>> a68_real_type = float_type_node;
>> a68_long_real_type = double_type_node;
>> a68_long_long_real_type = long_double_type_node;
>> + PUSH_TYPE ("REAL", a68_real_type);
>> + PUSH_TYPE ("LONG REAL", a68_long_real_type);
>> + PUSH_TYPE ("LONG LONG REAL", a68_long_long_real_type);
>> }
>>
>> /* Language hooks data structures. This is the main interface between
>> @@ -435,6 +459,16 @@ pushdecl (tree decl)
>> else
>> a68_add_decl (decl);
>>
>> + /* For the declaration of a type, set its name if it is not already set. */
>> +
>> + if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0)
>> + {
>> + if (DECL_SOURCE_LINE (decl) == 0)
>> + TYPE_NAME (TREE_TYPE (decl)) = decl;
>> + else
>> + TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl);
>> + }
>> +
>> return decl;
>> }
More information about the Algol68
mailing list