public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Martin Sebor <msebor@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	       Joseph Myers <joseph@codesourcery.com>,
	       Jason Merrill <jason@redhat.com>,
	David Malcolm <dmalcolm@redhat.com>
Subject: Re: C/C++ PATCH to implement -Wmultiline-expansion (PR c/80116)
Date: Thu, 08 Jun 2017 11:19:00 -0000	[thread overview]
Message-ID: <20170608111918.GS3413@redhat.com> (raw)
In-Reply-To: <298dff67-4f25-f4a7-2ad8-38e67a1cbf87@redhat.com>

On Thu, Jun 08, 2017 at 12:01:03PM +0100, Pedro Alves wrote:
> On 06/08/2017 11:29 AM, Marek Polacek wrote:
> > On Wed, Jun 07, 2017 at 08:02:42PM +0100, Pedro Alves wrote:
> >> Hi Marek,
> >>
> >> Nice warning!  Just to confirm, would the patch warn with code like:
> >  
> > Thanks.  BTW, if you (or anyone) could come up with a better name,
> > I'm all ears.
> 
> AFAICS, the warning's intent is catching the case of a
> a macro expanding to multiple (top level) statements, not lines.

True.  I felt that it was implicitly understood what's meant by that,
but I'll change that.  Martin pointed this out, too.

> Both the comments in the code and the description of the
> warning talk in those terms:
> 
>  +/* (....) This warning warns about
>  +   cases when a macro expands to multiple statements not wrapped in
>  +   do {} while (0) or ({ }) and is used as a body of if/else/for/while
>  +   conditionals.  For example,
> 
>  +Wmultiline-expansion
>  +C ObjC C++ ObjC++ Var(warn_multiline_expansion) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
>  +Warn about macros expanding to multiple statements in a body of a conditional such as if, else, while, or for.
> 
> So it'd seem clearer to me if the warning was named around
> "-Wmulti-statement-something" instead of "-Wmultiline-something"?
> 
>   -Wmulti-statement-expansion
>   -Wmulti-statement-macros     
>   -Wmulti-statement-macro     
>   -Wmulti-statement-macro-expansion

I think I'll go with -Wmultistatement-expansion (without the dash).

> Particularly when one could argue that "multiline expansion" in
> context of macros doesn't make any sense, given macros always
> expand to a single line:
> 
>  #define SAME_LINE				\
>  	(__LINE__				\
>  	 == __LINE__)
> 
>  static_assert (SAME_LINE, "");

Sure.

> > Nope, it doesn't warn (neither C nor C++).  I should probably add this test.
> 
> Thanks for confirming.  A test would be nice, to make sure we 
> don't regress.

I'll post a new version with the warning renamed and the new test added.

Thanks,

	Marek

  reply	other threads:[~2017-06-08 11:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 16:45 Marek Polacek
2017-06-01 18:08 ` David Malcolm
2017-06-01 22:13   ` Joseph Myers
2017-06-02 16:39     ` Marek Polacek
2017-06-02 16:37   ` Marek Polacek
2017-06-01 18:50 ` Trevor Saunders
2017-06-01 22:17 ` Martin Sebor
2017-06-02 16:53   ` Marek Polacek
2017-06-02 21:50     ` Martin Sebor
2017-06-07 18:44       ` Marek Polacek
2017-06-07 19:02         ` Pedro Alves
2017-06-08 10:29           ` Marek Polacek
2017-06-08 11:01             ` Pedro Alves
2017-06-08 11:19               ` Marek Polacek [this message]
2017-06-08 11:32                 ` Pedro Alves
2017-06-08 14:53                   ` Martin Sebor
2017-06-08 15:04                     ` Marek Polacek

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=20170608111918.GS3413@redhat.com \
    --to=polacek@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=msebor@gmail.com \
    --cc=palves@redhat.com \
    /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).