From db2534b704e5f1227decd2a0cfe62bff1d2bee65 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 27 Apr 2021 07:35:23 -0600 Subject: Fix Ada overloading with 'null' Currently, the Ada expression parser treats 'null' as an integer 0. However, this causes overloading to fail in certain cases. This patch changes the Ada expression parser to use a special type for 'null'. I chose pointer-to-int0, because I think that's not likely to be needed for any other Ada expression. Note this works because a "mod 1" type has an underlying non-zero byte size; the test includes a check for this. The output is changed so that "print null", by default, shows "null". And, ada_type_match is changed both to recognize the special null type and to remove a bit of weird code related to how pointers are treated for overload type matching. Tested on x86-64 Fedora 32. Because this only touches Ada, and Joel already approved it internally at AdaCore, I am checking it in. gdb/ChangeLog 2021-04-28 Tom Tromey * ada-exp.y (primary): Use new type for null pointer. * ada-lang.c (ada_type_match): Remove "may_deref" parameter. Handle null pointer. (ada_args_match): Update. * ada-valprint.c (ada_value_print_ptr, ada_value_print): Handle null pointer. gdb/testsuite/ChangeLog 2021-04-28 Tom Tromey * gdb.ada/null_overload.exp: New file. * gdb.ada/null_overload/foo.adb: New file. --- gdb/ada-exp.y | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gdb/ada-exp.y') diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 7b1b60f..3652376 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -891,7 +891,11 @@ primary : FLOAT ; primary : NULL_PTR - { write_int (pstate, 0, type_int (pstate)); } + { + struct type *null_ptr_type + = lookup_pointer_type (parse_type (pstate)->builtin_int0); + write_int (pstate, 0, null_ptr_type); + } ; primary : STRING -- cgit v1.1