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.
This commit is contained in:
Joel Brobecker 2013-11-27 18:47:40 +04:00
parent 849f2b52ec
commit 7fb1b8b13f
7 changed files with 113 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2013-12-03 Joel Brobecker <brobecker@adacore.com>
* ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp.
2013-12-03 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (create_excep_cond_exprs): Force EXP to NULL

View file

@ -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;
}

View file

@ -1,3 +1,7 @@
2013-12-03 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/dot_all: New testcase.
2013-12-03 Joel Brobecker <brobecker@adacore.com>
* gdb.mi/mi-undefined-cmd.exp: New testcase.

View file

@ -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 <http://www.gnu.org/licenses/>.
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"

View file

@ -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 <http://www.gnu.org/licenses/>.
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;

View file

@ -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 <http://www.gnu.org/licenses/>.
package body Pck is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;

View file

@ -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 <http://www.gnu.org/licenses/>.
with System;
package Pck is
procedure Do_Nothing (A : System.Address);
end Pck;