summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-05-26 14:11:08 -0600
committerTom Tromey <tromey@adacore.com>2020-05-26 14:11:08 -0600
commit0bc2354b811e913b39c288e74d7166eaa3639309 (patch)
treee807e4fde40111f355fd7605933120fe13e3d52c /gdb/testsuite/gdb.ada/arr_acc_idx_w_gap
parent0db49895f30daea6edcc57e4c5003fd02a747c2b (diff)
downloadbinutils-gdb-0bc2354b811e913b39c288e74d7166eaa3639309.tar.gz
Fix bugs in 'val and 'pos with range types
In Ada, the 'val and 'pos attributes can be used to map from an enumeration constant to its position in the enum and vice versa. These operators did not work properly when the type in question was a subrange of an enum type with "holes". gdb/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE. * gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE. gdb/testsuite/ChangeLog 2020-05-26 Tom Tromey <tromey@adacore.com> * gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests. * gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New type. * gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New variable.
Diffstat (limited to 'gdb/testsuite/gdb.ada/arr_acc_idx_w_gap')
-rw-r--r--gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads6
-rw-r--r--gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb1
2 files changed, 5 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads
index 6e073e88a49..719380077e1 100644
--- a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads
+++ b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads
@@ -34,14 +34,16 @@ package Enum_With_Gap is
);
for Enum_With_Gaps'size use 16;
+ type Enum_Subrange is new Enum_With_Gaps range Lit1 .. Lit3;
+
type MyWord is range 0 .. 16#FFFF# ;
for MyWord'Size use 16;
type AR is array (Enum_With_Gaps range <>) of MyWord;
type AR_Access is access AR;
-
+
type String_Access is access String;
-
+
procedure Do_Nothing (E : AR_Access);
procedure Do_Nothing (E : String_Access);
diff --git a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb
index da37dd7d5ec..752b8837980 100644
--- a/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb
+++ b/gdb/testsuite/gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb
@@ -19,6 +19,7 @@ procedure Enum_With_Gap_Main is
Indexed_By_Enum : AR_Access :=
new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41);
S : String_Access := new String'("Hello!");
+ V : Enum_Subrange := LIT3;
begin
Do_Nothing (Indexed_By_Enum); -- BREAK
Do_Nothing (S);