public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "momchil at xaxo dot eu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/48062] `shadowed declaration is here' should be a note
Date: Thu, 09 Jun 2011 01:46:00 -0000	[thread overview]
Message-ID: <bug-48062-4-kXnXfqb7j1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48062-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48062

momchil at xaxo dot eu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |momchil at xaxo dot eu

--- Comment #2 from momchil at xaxo dot eu 2011-06-09 01:46:43 UTC ---
Hi, there is an ambiguity here, consider the following examples:

$ cat > 1.c
int
main(void)
{
    int i;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
    { int i; }
#pragma GCC diagnostic pop
}

$ gcc46 -Wshadow 1.c
1.c: In function 'main':
1.c:4:6: warning: shadowed declaration is here [-Wshadow]

Here I would suppose to see no warning at all, because I have turned it off for
the case that shadows. But:

$ cat > 2.c
int
main(void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
    int i;
#pragma GCC diagnostic pop

    {int i;}
}
$ gcc46 -Wshadow 2.c
2.c: In function 'main':
2.c:9:7: warning: declaration of 'i' shadows a previous local [-Wshadow]

And it is something that I whould also not expect. And now:

$ cat > 3.c
int
main(void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
    int i;
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
    { int i; }
#pragma GCC diagnostic pop
}
$ gcc46 -Wshadow 3.c

Produces no warning. So for me it is a bit confusing, since the warning setting
refers to pieces of code and not to variables.


  parent reply	other threads:[~2011-06-09  1:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10 16:42 [Bug c/48062] New: " d.g.gorbachev at gmail dot com
2011-03-10 18:44 ` [Bug c/48062] " manu at gcc dot gnu.org
2011-06-09  1:46 ` momchil at xaxo dot eu [this message]
2011-06-09  7:55 ` manu at gcc dot gnu.org
2012-02-13 17:25 ` manu at gcc dot gnu.org
2014-06-03 16:57 ` mpolacek at gcc dot gnu.org
2014-06-05  5:31 ` mpolacek at gcc dot gnu.org
2014-06-05  6:21 ` mpolacek at gcc dot gnu.org

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=bug-48062-4-kXnXfqb7j1@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).