Fix type name in ptype-o.exp

The "Rec" type in ptype-o.exp is currently named "prog__rec" by the
compiler.  However, with my changes to GNAT, the type will no longer
have a prefix, as it is local to a procedure.

Changing this to just use "rec" works fine with the new compiler, but
then fails with older compilers.  To allow correct operation with both
compilers, this patch simply moves the type into a new package.  This
doesn't affect the meaning of the test, which is just ensuring that
ptype/o works in a certain case.

Note that the more obvious fix of just using "ptype/o rec" does not
work with the current GNAT.  I haven't investigated this but I did
file a bug to track it:

    https://sourceware.org/bugzilla/show_bug.cgi?id=32169
This commit is contained in:
Tom Tromey
2024-09-12 08:18:10 -06:00
parent cabd5456c7
commit fb77dfe48b
3 changed files with 28 additions and 10 deletions

View File

@@ -43,5 +43,5 @@ foreach_gnat_encoding scenario flags {all minimal} {
# crash.
set exp ".*"
}
gdb_test "ptype/o prog__rec" $exp
gdb_test "ptype/o pck__rec" $exp
}

View File

@@ -0,0 +1,25 @@
-- Copyright 2023-2024 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 Pck is
type Index is range 0 .. 31;
type Char_Array is array ( Index range <>) of Character;
type Rec (Length : Index) is
record
TV_Description : Char_Array (1 .. Length);
Note : Char_Array (1 .. Length);
end record;
end Pck;

View File

@@ -13,16 +13,9 @@
-- 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 Prog is
type Index is range 0 .. 31;
type Char_Array is array ( Index range <>) of Character;
type Rec (Length : Index) is
record
TV_Description : Char_Array (1 .. Length);
Note : Char_Array (1 .. Length);
end record;
X : Rec (7);
begin
null; -- BREAK