aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2015-09-02 18:18:15 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2015-09-03 17:52:05 +0200
commitcd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a (patch)
treeadb1f446aa66ec2914134cdf2d4845f6168d560c /gdb/ada-lang.c
parenta5e406b5ada4fc7e5131dc4242b6cf46c6139a3f (diff)
downloadfsf-binutils-gdb-cd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a.zip
fsf-binutils-gdb-cd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a.tar.gz
fsf-binutils-gdb-cd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a.tar.bz2
[Ada] Make string_char_type a true TYPE_CODE_CHAR type in Ada
Before this change, trying to call an overloaded function with at least one character literal in argument would fail. For instance, given these two functions: function F (C : Character) return Integer is begin return Character'Pos (C); end F; function F (I : Integer) return Integer is begin return -I; end F; We would get the following GDB session: (gdb) p f('A') $1 = -65 (gdb) p f(1) $1 = -1 This is wrong because the first call should select the first F function and thus return 65. The root problem is that ada-lang.c:ada_language_arch_info stores in string_char_type a type whose code is TYPE_CODE_INT instead of TYPE_CODE_CHAR. As a result, all parsed character literals are turned into integer values and during overload matching, the TYPE_CODE_CHAR formal rejects the TYPE_CODE_INT actual. This change turns string_char_type into a true TYPE_CODE_CHAR type in ada-lang.c so that we have instead the expected: (gdb) p f('A') $1 = 65 gdb/ChangeLog: * ada-lang.c (ada_language_arch_info): Create a TYPE_CODE_CHAR type instead of a TYPE_CODE_INT one for the string_char_type and the ada_primitive_type_char types. gdb/testsuite/ChangeLog: * gdb.ada/funcall_char.exp: New testcase. * gdb.ada/funcall_char/foo.adb: New file. Tested on x86_64-linux, no regression.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a7809ff..5604849 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13775,7 +13775,7 @@ ada_language_arch_info (struct gdbarch *gdbarch,
0, "short_integer");
lai->string_char_type
= lai->primitive_type_vector [ada_primitive_type_char]
- = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
+ = arch_character_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
lai->primitive_type_vector [ada_primitive_type_float]
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
"float", NULL);