From: Joel Brobecker Date: Wed, 27 Nov 2013 14:47:40 +0000 (+0400) Subject: Ada: Reserved word "all" should not need to be spelled in lowercase. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7fb1b8b13f1fb3a72f0ab3ce72967549ea040e17;p=binutils-gdb.git Ada: Reserved word "all" should not need to be spelled in lowercase. Consider the following code: type Ptr is access all Integer; IP : Ptr := new Integer'(123); IP is the Ada exception of a pointer to an integer. To dereference the pointer and get its value, the user uses the reserved word "all" as follow: (gdb) p ip.all $1 = 123 Ada being a case-insensitive language, the casing should not matter. Unfortunately, for the reserved word "all", things don't work. For instance: (gdb) p ip.ALL Type integer is not a structure or union type This patch fixes the problem. gdb/ChangeLog: * ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp. gdb/testsuite/ChangeLog: * gdb.ada/dot_all: New testcase. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6e4b9a5a301..cbf40398b93 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2013-12-03 Joel Brobecker + + * ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp. + 2013-12-03 Joel Brobecker * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 3c30043323c..8ad825b1bfa 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -545,7 +545,7 @@ find_dot_all (const char *str) do i += 1; while (isspace (str[i])); - if (strncmp (str+i, "all", 3) == 0 + if (strncasecmp (str+i, "all", 3) == 0 && ! isalnum (str[i+3]) && str[i+3] != '_') return i0; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bc4bcbbaa7f..5725b3d1a7c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-12-03 Joel Brobecker + + * gdb.ada/dot_all: New testcase. + 2013-12-03 Joel Brobecker * gdb.mi/mi-undefined-cmd.exp: New testcase. diff --git a/gdb/testsuite/gdb.ada/dot_all.exp b/gdb/testsuite/gdb.ada/dot_all.exp new file mode 100644 index 00000000000..87a248fa4af --- /dev/null +++ b/gdb/testsuite/gdb.ada/dot_all.exp @@ -0,0 +1,34 @@ +# Copyright 2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "ada.exp" + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] +if ![runto "foo.adb:$bp_location" ] then { + perror "Couldn't run ${testfile}" + return +} + +gdb_test "print addr.all" " = 123" +gdb_test "print addr.ALL" " = 123" +gdb_test "print addr.AlL" " = 123" diff --git a/gdb/testsuite/gdb.ada/dot_all/foo.adb b/gdb/testsuite/gdb.ada/dot_all/foo.adb new file mode 100644 index 00000000000..1bf079745fa --- /dev/null +++ b/gdb/testsuite/gdb.ada/dot_all/foo.adb @@ -0,0 +1,23 @@ +-- Copyright 2013 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Pck; use Pck; + +procedure Foo is + type Integer_Access is access all Integer; + Addr : Integer_Access := new Integer'(123); +begin + Do_Nothing (Addr'Address); -- STOP +end Foo; diff --git a/gdb/testsuite/gdb.ada/dot_all/pck.adb b/gdb/testsuite/gdb.ada/dot_all/pck.adb new file mode 100644 index 00000000000..39ce769477d --- /dev/null +++ b/gdb/testsuite/gdb.ada/dot_all/pck.adb @@ -0,0 +1,25 @@ +-- Copyright 2008-2013 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package body Pck is + + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; + +end Pck; + + diff --git a/gdb/testsuite/gdb.ada/dot_all/pck.ads b/gdb/testsuite/gdb.ada/dot_all/pck.ads new file mode 100644 index 00000000000..771b5c1a1a1 --- /dev/null +++ b/gdb/testsuite/gdb.ada/dot_all/pck.ads @@ -0,0 +1,22 @@ +-- Copyright 2008-2013 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with System; + +package Pck is + procedure Do_Nothing (A : System.Address); +end Pck; + +