public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] gdb: fix variable shadowing error in darwin-nat.c
Date: Thu, 23 Jan 2020 23:30:00 -0000	[thread overview]
Message-ID: <ab53f3826242df0f051f9a6fa4b2926687205025@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT ab53f3826242df0f051f9a6fa4b2926687205025 ***

commit ab53f3826242df0f051f9a6fa4b2926687205025
Author:     Simon Marchi <simon.marchi@efficios.com>
AuthorDate: Thu Jan 23 17:44:22 2020 -0500
Commit:     Simon Marchi <simon.marchi@efficios.com>
CommitDate: Thu Jan 23 17:44:22 2020 -0500

    gdb: fix variable shadowing error in darwin-nat.c
    
    We encounter this error when building on macOS with GCC.
    
      CXX    darwin-nat.o
    /src-local/binutils-gdb/gdb/darwin-nat.c: In member function 'ptid_t darwin_nat_target::wait_1(ptid_t, target_waitstatus*)':
    /src-local/binutils-gdb/gdb/darwin-nat.c:1264:18: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local]
       for (inferior *inf : all_inferiors (this))
                      ^~~
    /src-local/binutils-gdb/gdb/darwin-nat.c:1205:20: note: shadowed declaration is here
       struct inferior *inf;
                        ^~~
    
    Fix it by moving the declaration of `inf` in the specific scopes that
    need it.  I think it's clearer this way anyway, as it shows that it's
    not the same `inf` that is used in these different scopes.
    
    Thanks to Iain Sandoe for reporting this.  I did not see this error at
    first, because I compile with the default system compiler on macOS,
    which is clang.  The compiler flag we try to enable for this is
    `-Wshadow=local`, which is not one recognized by clang.  I checked to
    see if there would a version of the -Wshadow* warnings [1] we could
    enable for clang, that would catch this, but the only one that would is
    `-Wshadow` itself, and this is too invasive for us (which is why we
    enabled just -Wshadow=local in the first place).
    
    [1] https://clang.llvm.org/docs/DiagnosticsReference.html#wshadow
    
    gdb/ChangeLog:
    
            * darwin-nat.c (darwin_nat_target::wait_1): Move `inf`
            declaration to narrower scopes.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b1c437bfd2..a37affef5b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-23  Simon Marchi  <simon.marchi@efficios.com>
+
+	* darwin-nat.c (darwin_nat_target::wait_1): Move `inf`
+	declaration to narrower scopes.
+
 2020-01-23  Simon Marchi  <simon.marchi@efficios.com>
 
 	* darwin-nat.h (struct darwin_exception_msg, enum
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 27677d16ea..3bd8d8ce00 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1202,7 +1202,6 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
   mach_msg_header_t *hdr = &msgin.hdr;
   ptid_t res;
   darwin_thread_t *thread;
-  struct inferior *inf;
 
   inferior_debug
     (2, _("darwin_wait: waiting for a message pid=%d thread=%lx\n"),
@@ -1211,7 +1210,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
   /* Handle fake stop events at first.  */
   if (darwin_inf_fake_stop != NULL)
     {
-      inf = darwin_inf_fake_stop;
+      inferior *inf = darwin_inf_fake_stop;
       darwin_inf_fake_stop = NULL;
 
       darwin_inferior *priv = get_darwin_inferior (inf);
@@ -1250,6 +1249,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
       if (darwin_debug_flag > 10)
 	darwin_dump_message (hdr, darwin_debug_flag > 11);
 
+      inferior *inf;
       res = decode_message (hdr, &thread, &inf, status);
       if (res == minus_one_ptid)
 	continue;
@@ -1290,6 +1290,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
       if (darwin_debug_flag > 10)
 	darwin_dump_message (hdr, darwin_debug_flag > 11);
 
+      inferior *inf;
       ptid2 = decode_message (hdr, &thread, &inf, &status2);
 
       if (inf != NULL && thread != NULL


             reply	other threads:[~2020-01-23 23:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 23:30 gdb-buildbot [this message]
2020-01-23 23:15 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2020-01-23 23:36 ` Failures on Fedora-i686, " gdb-buildbot
2020-01-23 23:38 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-23 23:45 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-01-23 23:50 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-23 23:51 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-23 23:51 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-24  0:26 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-24  0:37 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-24  1:00 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab53f3826242df0f051f9a6fa4b2926687205025@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).