This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 17/348] Fix -Wshadow warnings


Hi Andrey,

>  2011-11-19  Andrey Smirnov <andrew.smirnov@gmail.com>
>  
> +	* ada-valprint.c (ada_val_print_1): Fix -Wshadow warnings.

Your patch didn't apply anymore, so I redid it along the same
lines, with a couple of minor modifications.  To produce a more
readable patch, which shows the significant part of the changes,
I produced a diff where whitespace changes are ignored.

Tested on x86_64-linux, checked in.

-- 
Joel
>From 2b814ac2e382b4294e6d2838908a08c75968f7bb Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 29 Mar 2012 11:44:26 -0700
Subject: [PATCH] Fix -Wshadow error in ada-valprint.c

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Move the code handling
        TYPE_CODE_ENUM inside its own lexical block.  Declare
        variables len and val there, instead of in the function's
        top level block.  Avoid declaring deref_val again in a way
        that shadows another variable of the same name declared
        in one of the up-level blocks.  Just re-use the up-level
        variable instead.
---
 gdb/ChangeLog      |   11 +++++++++++
 gdb/ada-valprint.c |    9 ++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0c50bc8..97aba93 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,15 @@
 2012-03-29  Joel Brobecker  <brobecker@adacore.com>
+	    Andrey Smirnov  <andrew.smirnov@gmail.com>
+
+	* ada-valprint.c (ada_val_print_1): Move the code handling
+	TYPE_CODE_ENUM inside its own lexical block.  Declare
+	variables len and val there, instead of in the function's
+	top level block.  Avoid declaring deref_val again in a way
+	that shadows another variable of the same name declared
+	in one of the up-level blocks.  Just re-use the up-level
+	variable instead.
+
+2012-03-29  Joel Brobecker  <brobecker@adacore.com>
 
 	* ada-lang.c (ada_lookup_encoded_symbol): Now returns void.
 	Replace block_found argument by symbol_info.  Adjust
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index a8351dd..1ec62ce 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -659,10 +659,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 		 const struct value *original_value,
 		 const struct value_print_options *options)
 {
-  unsigned int len;
   int i;
   struct type *elttype;
-  LONGEST val;
   int offset_aligned;
 
   type = ada_check_typedef (type);
@@ -811,6 +809,10 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 	}
 
     case TYPE_CODE_ENUM:
+      {
+	unsigned int len;
+	LONGEST val;
+
       if (options->format)
 	{
 	  val_print_scalar_formatted (type, valaddr, offset_aligned,
@@ -841,6 +843,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 	  print_longest (stream, 'd', 0, val);
 	}
       break;
+      }
 
     case TYPE_CODE_FLT:
       if (options->format)
@@ -897,7 +900,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
           deref_val_int = unpack_pointer (type, valaddr + offset_aligned);
           if (deref_val_int != 0)
             {
-              struct value *deref_val =
+              deref_val =
                 ada_value_ind (value_from_pointer
                                (lookup_pointer_type (elttype),
                                 deref_val_int));
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]