aboutsummaryrefslogtreecommitdiff
path: root/gdb/nios2-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-21 16:16:27 -0600
committerTom Tromey <tom@tromey.com>2018-10-04 22:51:45 -0600
commitb926417afaea99ed17663e06d6654d0048536017 (patch)
treeb26a979c2f74c28f5c8979f55acfdacefdb18cfb /gdb/nios2-tdep.c
parent1f88d0c87c37d3a15fa6376335e8b0d1c79d85aa (diff)
downloadgdb-b926417afaea99ed17663e06d6654d0048536017.zip
gdb-b926417afaea99ed17663e06d6654d0048536017.tar.gz
gdb-b926417afaea99ed17663e06d6654d0048536017.tar.bz2
Simple -Wshadow=local fixes
This fixes all the straightforward -Wshadow=local warnings in gdb. A few standard approaches are used here: * Renaming an inner (or outer, but more commonly inner) variable; * Lowering a declaration to avoid a clash; * Moving a declaration into a more inner scope to avoid a clash, including the special case of moving a declaration into a loop header. I did not consider any of the changes in this patch to be particularly noteworthy, though of course they should all still be examined. gdb/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> * ctf.c (SET_ARRAY_FIELD): Rename "u32". * p-valprint.c (pascal_val_print): Split inner "i" variable. * xtensa-tdep.c (xtensa_push_dummy_call): Declare "i" in loop header. * xstormy16-tdep.c (xstormy16_push_dummy_call): Declare "val" in more inner scope. * xcoffread.c (read_xcoff_symtab): Rename inner "symbol". * varobj.c (varobj_update): Rename inner "newobj", "type_changed". * valprint.c (generic_emit_char): Rename inner "buf". * valops.c (find_overload_match): Rename inner "temp". (value_struct_elt_for_reference): Declare "v" in more inner scope. * v850-tdep.c (v850_push_dummy_call): Rename "len". * unittests/array-view-selftests.c (run_tests): Rename inner "vec". * tui/tui-stack.c (tui_show_frame_info): Declare "i" in loop header. * tracepoint.c (merge_uploaded_trace_state_variables): Declare "tsv" in more inner scope. (print_one_static_tracepoint_marker): Rename inner "tuple_emitter". * tic6x-tdep.c (tic6x_analyze_prologue): Declare "inst" lower. (tic6x_push_dummy_call): Don't redeclare "addr". * target-float.c: Declare "dto" lower. * symtab.c (lookup_local_symbol): Rename inner "sym". (find_pc_sect_line): Rename inner "pc". * stack.c (print_frame): Don't redeclare "gdbarch". (return_command): Rename inner "gdbarch". * s390-tdep.c (s390_prologue_frame_unwind_cache): Renam inner "sp". * rust-lang.c (rust_internal_print_type): Declare "i" in loop header. * rs6000-tdep.c (ppc_process_record): Rename inner "addr". * riscv-tdep.c (riscv_push_dummy_call): Declare "info" in inner scope. * remote.c (remote_target::update_thread_list): Don't redeclare "tp". (remote_target::process_initial_stop_replies): Rename inner "thread". (remote_target::remote_parse_stop_reply): Don't redeclare "p". (remote_target::wait_as): Don't redeclare "stop_reply". (remote_target::get_thread_local_address): Rename inner "result". (remote_target::get_tib_address): Likewise.
Diffstat (limited to 'gdb/nios2-tdep.c')
-rw-r--r--gdb/nios2-tdep.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index 008b1d4..c972b4b 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -1202,8 +1202,6 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
struct reg_value *value = cache->reg_value;
struct reg_value temp_value[NIOS2_NUM_REGS];
- int i;
-
/* Save the starting PC so we can correct the pc after running
through the prolog, using symbol info. */
CORE_ADDR pc = start_pc;
@@ -1285,7 +1283,7 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
/* If any registers were saved on the stack before then
we can't backtrace into them now. */
- for (i = 0 ; i < NIOS2_NUM_REGS ; i++)
+ for (int i = 0 ; i < NIOS2_NUM_REGS ; i++)
{
if (cache->reg_saved[i].basereg == NIOS2_SP_REGNUM)
cache->reg_saved[i].basereg = -1;
@@ -1416,7 +1414,6 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
/* PUSH.N {reglist}, adjust
or
STWM {reglist}, --(SP)[, writeback] */
- int i;
int off = 0;
if (ra != NIOS2_SP_REGNUM || id != 0)
@@ -1424,7 +1421,7 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
part of the prologue. */
break;
- for (i = 31; i >= 0; i--)
+ for (int i = 31; i >= 0; i--)
if (reglist & (1 << i))
{
int orig = value[i].reg;
@@ -1469,9 +1466,9 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
if ra has been stored into r8 beforehand and if it's
before the stack adjust.
Note mcount corrupts r2-r3, r9-r15 & ra. */
- for (i = 2 ; i <= 3 ; i++)
+ for (int i = 2 ; i <= 3 ; i++)
value[i].reg = -1;
- for (i = 9 ; i <= 15 ; i++)
+ for (int i = 9 ; i <= 15 ; i++)
value[i].reg = -1;
value[NIOS2_RA_REGNUM].reg = -1;
@@ -1621,14 +1618,14 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
/* Adjust all the saved registers such that they contain addresses
instead of offsets. */
- for (i = 0; i < NIOS2_NUM_REGS; i++)
+ for (int i = 0; i < NIOS2_NUM_REGS; i++)
if (cache->reg_saved[i].basereg == NIOS2_SP_REGNUM)
{
cache->reg_saved[i].basereg = NIOS2_Z_REGNUM;
cache->reg_saved[i].addr += frame_high;
}
- for (i = 0; i < NIOS2_NUM_REGS; i++)
+ for (int i = 0; i < NIOS2_NUM_REGS; i++)
if (cache->reg_saved[i].basereg == NIOS2_GP_REGNUM)
{
CORE_ADDR gp = get_frame_register_unsigned (this_frame,
@@ -1818,7 +1815,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
int argreg;
int argnum;
- int len = 0;
+ int arg_space = 0;
int stack_offset = 0;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1828,8 +1825,8 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* Now make space on the stack for the args. */
for (argnum = 0; argnum < nargs; argnum++)
- len += align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
- sp -= len;
+ arg_space += align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
+ sp -= arg_space;
/* Initialize the register pointer. */
argreg = NIOS2_FIRST_ARGREG;