Ada character types : tree code and DW_AT_encoding
Jerome Guitton
guitton@adacore.com
Tue Jul 5 10:53:00 GMT 2005
Hello,
dwarf2out.c reads:
[...]
case CHAR_TYPE:
/* GNU Pascal/Ada CHAR type. Not used in C. */
if (TREE_UNSIGNED (type))
encoding = DW_ATE_unsigned_char;
else
encoding = DW_ATE_signed_char;
break;
[...]
The comment is wrong. In Ada, the tree code for a character type is
INTEGER_TYPE. That means that a wrong value is generated for the tag
DW_AT_encoding.
Two solutions : we can either change the tree code to CHAR_TYPE or add a test
to detect Ada character types in the INTEGER_TYPE case, like it is done for
C:
[...]
case INTEGER_TYPE:
/* Carefully distinguish the C character types, without messing
up if the language is not C. Note that we check only for the names
that contain spaces; other names might occur by coincidence in other
languages. */
if (! (TYPE_PRECISION (type) == CHAR_TYPE_SIZE
&& (type == char_type_node
|| ! strcmp (type_name, "signed char")
|| ! strcmp (type_name, "unsigned char"))))
{
if (TREE_UNSIGNED (type))
encoding = DW_ATE_unsigned;
else
encoding = DW_ATE_signed;
break;
}
[...]
The first solution would probably be cleaner, but it would mean that
Ada would be the only supported langage to use CHAR_TYPE. The second
one would be safer.
Opinions/thoughts?
Thanks in advance,
Jerome
More information about the Gcc
mailing list