aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-28 12:42:51 -0600
committerTom Tromey <tromey@adacore.com>2023-08-29 13:36:55 -0600
commit0f2d28db8e9c7a6b598370a2a93bcb9ae7f0df96 (patch)
tree9f0ac62e94667504e696d14468216ce169268efd /gdb
parentc73556cb0e6da3c2a4484975ee51e052a9be8b36 (diff)
downloadgdb-0f2d28db8e9c7a6b598370a2a93bcb9ae7f0df96.zip
gdb-0f2d28db8e9c7a6b598370a2a93bcb9ae7f0df96.tar.gz
gdb-0f2d28db8e9c7a6b598370a2a93bcb9ae7f0df96.tar.bz2
Declare 'tem' in loop header in array_operation::evaluate
This changes array_operation::evaluate to declare the 'tem' variable in the loop header, rather than at the top of the function. This is cleaner and easier to reason about. I also changed 'nargs' to be 'const'. Reviewed-by: John Baldwin <jhb@FreeBSD.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/eval.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 00b9231..63c414e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2397,11 +2397,10 @@ array_operation::evaluate (struct type *expect_type,
struct expression *exp,
enum noside noside)
{
- int tem;
int tem2 = std::get<0> (m_storage);
int tem3 = std::get<1> (m_storage);
const std::vector<operation_up> &in_args = std::get<2> (m_storage);
- int nargs = tem3 - tem2 + 1;
+ const int nargs = tem3 - tem2 + 1;
struct type *type = expect_type ? check_typedef (expect_type) : nullptr;
if (expect_type != nullptr
@@ -2429,7 +2428,7 @@ array_operation::evaluate (struct type *expect_type,
}
index = low_bound;
memset (array->contents_raw ().data (), 0, expect_type->length ());
- for (tem = nargs; --nargs >= 0;)
+ for (int tem = 0; tem < nargs; ++tem)
{
struct value *element;
@@ -2467,7 +2466,7 @@ array_operation::evaluate (struct type *expect_type,
error (_("(power)set type with unknown size"));
memset (valaddr, '\0', type->length ());
int idx = 0;
- for (tem = 0; tem < nargs; tem++)
+ for (int tem = 0; tem < nargs; tem++)
{
LONGEST range_low, range_high;
struct type *range_low_type, *range_high_type;
@@ -2516,7 +2515,7 @@ array_operation::evaluate (struct type *expect_type,
}
std::vector<value *> argvec (nargs);
- for (tem = 0; tem < nargs; tem++)
+ for (int tem = 0; tem < nargs; tem++)
{
/* Ensure that array expressions are coerced into pointer
objects. */