public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: "gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix -Wshadow=local warnings in dumpfile.h
Date: Fri, 04 Oct 2019 12:16:00 -0000	[thread overview]
Message-ID: <mpt8sq0n1sl.fsf@arm.com> (raw)
In-Reply-To: <VI1PR03MB4528A51B7A77C6EA3CFC8C54E49F0@VI1PR03MB4528.eurprd03.prod.outlook.com>	(Bernd Edlinger's message of "Thu, 3 Oct 2019 15:18:40 +0000")

Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> Hi,
>
> this fixes a -Wshadow=local warning when using AUTO_DUMP_SCOPE in
> nested blocks.  Since NAME i a string I cannot use it to create
> a unique name for the auto_dump_scope object.
>
> So I used XCONCAT2 from good old symcat.h, to mangle the __LINE__
> macro into the scope object name.

Seems a pity to reintroduce uses of symcat.h again now when it was
originally only a bridge from pre-ISO C.  How about just importing
XCONCAT2 into system.h instead?  I guess it's a bit of an abuse of
system.h, but not really much worse than CEIL, ROUND_UP, etc., and
that's where symcat.h was originally included.

Thanks,
Richard

> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
>
>
> Thanks
> Bernd.
>
> 2019-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>
> 	* dumpfile.h (AUTO_DUMP_SCOPE): Use XCONCAT2 and __LINE__
> 	to form a unique name for the scope variable.
>
> Index: gcc/dumpfile.h
> ===================================================================
> --- gcc/dumpfile.h	(revision 276484)
> +++ gcc/dumpfile.h	(working copy)
> @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
>  #ifndef GCC_DUMPFILE_H
>  #define GCC_DUMPFILE_H 1
>  
> +#include "symcat.h" /* XCONCAT2 */
>  #include "profile-count.h"
>  
>  /* An attribute for annotating formatting printing functions that use
> @@ -634,7 +635,7 @@ class auto_dump_scope
>     in a nested scope implicitly default to MSG_PRIORITY_INTERNALS.  */
>  
>  #define AUTO_DUMP_SCOPE(NAME, USER_LOC) \
> -  auto_dump_scope scope (NAME, USER_LOC)
> +  auto_dump_scope XCONCAT2 (scope, __LINE__) (NAME, USER_LOC)
>  
>  extern void dump_function (int phase, tree fn);
>  extern void print_combine_total_stats (void);

  reply	other threads:[~2019-10-04 12:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 15:18 Bernd Edlinger
2019-10-04 12:16 ` Richard Sandiford [this message]
2019-10-04 18:00   ` Bernd Edlinger

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=mpt8sq0n1sl.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=gcc-patches@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).