This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] [Ada] Make string_char_type a true TYPE_CODE_CHAR type in Ada
- From: sergiodj+buildbot at redhat dot com
- To: gdb-testers at sourceware dot org
- Date: Thu, 03 Sep 2015 12:02:32 -0400
- Subject: [binutils-gdb] [Ada] Make string_char_type a true TYPE_CODE_CHAR type in Ada
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT cd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a ***
Author: Pierre-Marie de Rodat <derodat@adacore.com>
Branch: master
Commit: cd7c1778e72ce29f7f42d91ab08ae855c7ef8f7a
[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.
- Follow-Ups:
- Failures on RHEL-s390x-m64, branch master
- Failures on Fedora-i686, branch master
- Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master
- Failures on Fedora-x86_64-native-gdbserver-m64, branch master
- Failures on Fedora-x86_64-native-gdbserver-m32, branch master
- Failures on Fedora-x86_64-m64, branch master
- Failures on Fedora-s390x-m64, branch master
- Failures on AIX-POWER7-plain, branch master
- Failures on Fedora-ppc64be-native-gdbserver-m64, branch master
- Failures on Debian-i686-native-gdbserver, branch master
- Failures on Fedora-ppc64be-native-extended-gdbserver-m64, branch master
- Failures on Debian-x86_64-native-extended-gdbserver-m64, branch master
- Failures on Debian-i686-native-extended-gdbserver, branch master
- Failures on Debian-x86_64-m64, branch master
- Failures on Debian-x86_64-native-gdbserver-m64, branch master