+2019-06-19 Tom Tromey <tromey@adacore.com>
+
+ * ada-lang.c (ada_evaluate_subexp) <case OP_ATR_FIRST>: Handle
+ EVAL_AVOID_SIDE_EFFECTS specially.
+
2019-06-19 Tom Tromey <tromey@adacore.com>
* source-cache.c (highlighter): New global.
if (noside == EVAL_SKIP)
goto nosideret;
+ else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ if (type_arg == NULL)
+ type_arg = value_type (arg1);
+
+ if (ada_is_constrained_packed_array_type (type_arg))
+ type_arg = decode_constrained_packed_array_type (type_arg);
- if (type_arg == NULL)
+ if (!discrete_type_p (type_arg))
+ {
+ switch (op)
+ {
+ default: /* Should never happen. */
+ error (_("unexpected attribute encountered"));
+ case OP_ATR_FIRST:
+ case OP_ATR_LAST:
+ type_arg = ada_index_type (type_arg, tem,
+ ada_attribute_name (op));
+ break;
+ case OP_ATR_LENGTH:
+ type_arg = builtin_type (exp->gdbarch)->builtin_int;
+ break;
+ }
+ }
+
+ return value_zero (type_arg, not_lval);
+ }
+ else if (type_arg == NULL)
{
arg1 = ada_coerce_ref (arg1);
type = builtin_type (exp->gdbarch)->builtin_int;
}
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return allocate_value (type);
-
switch (op)
{
default: /* Should never happen. */
type = builtin_type (exp->gdbarch)->builtin_int;
}
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return allocate_value (type);
-
switch (op)
{
default:
+2019-06-19 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/length_cond.exp: New file.
+ * gdb.ada/length_cond/length_cond.adb: New file.
+ * gdb.ada/length_cond/pck.adb: New file.
+ * gdb.ada/length_cond/pck.ads: New file.
+
2019-06-18 Tom de Vries <tdevries@suse.de>
* boards/fission.exp (debug_flags): Add "-fuse-ld=gold".
--- /dev/null
+# Copyright 2019 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 length_cond
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAKPOINT" ${testdir}/length_cond.adb]
+gdb_breakpoint length_cond.adb:$bp_location message
+
+# Resolving the conditional expression would cause a crash, so it's
+# enough to just set the conditions.
+
+foreach var {loc enum_val int_val} {
+ foreach attr {first last} {
+ gdb_test_no_output "cond 1 $var'$attr > 15"
+ }
+}
+
+gdb_test_no_output "cond 1 loc'length > 15"
+
+foreach attr {first last length} {
+ foreach val {1 2} {
+ gdb_test_no_output "cond 1 my_array'${attr}($val) > 15"
+ }
+}
--- /dev/null
+-- Copyright 2019 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;
+
+procedure Length_Cond is
+ type Enum is (One, Two, Three);
+ Enum_Val : Enum := Three;
+
+ type My_Int is range -23 .. 23;
+ Int_Val : My_Int := 0;
+
+ type My_Array is array (0..1, 0..1) of Boolean;
+ Array_Val : My_Array := ((True, False), (False, True));
+
+ procedure p (s : String) is
+ loc : String := s & ".";
+ begin
+ Pck.Do_Nothing (loc); -- BREAKPOINT
+ end p;
+begin
+ for I in 1 .. 25 loop
+ p ((1 .. I => 'X'));
+ end loop;
+end Length_Cond;
--- /dev/null
+-- Copyright 2019 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 : String) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
--- /dev/null
+-- Copyright 2019 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
+ procedure Do_Nothing (A : String);
+end Pck;