From 7b9f71f2886b62bb3c0e2b5df7cbcf1ff70d77b5 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 24 Dec 2007 06:29:27 +0000 Subject: [PATCH] * dwarf2read.c (read_base_type): Set code to TYPE_CODE_CHAR for char and unsigned char types of Ada compilation units. * ada-lang.c (ada_is_character_type): Always return true if the type code is TYPE_CODE_CHAR. --- gdb/ChangeLog | 7 +++++++ gdb/ada-lang.c | 25 ++++++++++++++++--------- gdb/dwarf2read.c | 4 ++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ba706319700..716c12b3038 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2007-12-24 Joel Brobecker + + * dwarf2read.c (read_base_type): Set code to TYPE_CODE_CHAR + for char and unsigned char types of Ada compilation units. + * ada-lang.c (ada_is_character_type): Always return true if + the type code is TYPE_CODE_CHAR. + 2007-12-23 Joel Brobecker * infrun.c (handle_inferior_event): Remove code that made us diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d549662ef1c..83afdd70bba 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7286,15 +7286,22 @@ value_val_atr (struct type *type, struct value *arg) int ada_is_character_type (struct type *type) { - const char *name = ada_type_name (type); - return - name != NULL - && (TYPE_CODE (type) == TYPE_CODE_CHAR - || TYPE_CODE (type) == TYPE_CODE_INT - || TYPE_CODE (type) == TYPE_CODE_RANGE) - && (strcmp (name, "character") == 0 - || strcmp (name, "wide_character") == 0 - || strcmp (name, "unsigned char") == 0); + const char *name; + + /* If the type code says it's a character, then assume it really is, + and don't check any further. */ + if (TYPE_CODE (type) == TYPE_CODE_CHAR) + return 1; + + /* Otherwise, assume it's a character type iff it is a discrete type + with a known character type name. */ + name = ada_type_name (type); + return (name != NULL + && (TYPE_CODE (type) == TYPE_CODE_INT + || TYPE_CODE (type) == TYPE_CODE_RANGE) + && (strcmp (name, "character") == 0 + || strcmp (name, "wide_character") == 0 + || strcmp (name, "unsigned char") == 0)); } /* True if TYPE appears to be an Ada string type. */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 48f02dd7670..e47ef93f301 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5007,11 +5007,11 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type_flags |= TYPE_FLAG_UNSIGNED; break; case DW_ATE_signed_char: - if (cu->language == language_m2) + if (cu->language == language_ada && cu->language == language_m2) code = TYPE_CODE_CHAR; break; case DW_ATE_unsigned_char: - if (cu->language == language_m2) + if (cu->language == language_ada && cu->language == language_m2) code = TYPE_CODE_CHAR; type_flags |= TYPE_FLAG_UNSIGNED; break; -- 2.30.2