public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Gerald Pfeifer <gerald@pfeifer.com>
Cc: David Malcolm <dmalcolm@redhat.com>,
	Martin Sebor <msebor@gmail.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	       Joseph Myers <joseph@codesourcery.com>,
	       Martin Sebor <msebor@redhat.com>,
	Jason Merrill <jason@redhat.com>
Subject: Re: C/C++ PATCH to implement -Wmultistatement-macros (PR c/80116)
Date: Tue, 13 Jun 2017 13:46:00 -0000	[thread overview]
Message-ID: <20170613134527.GB3413@redhat.com> (raw)
In-Reply-To: <alpine.LSU.2.21.1706092358030.5843@anthias.pfeifer.com>

On Sat, Jun 10, 2017 at 12:03:18AM +0200, Gerald Pfeifer wrote:
> On Thu, 8 Jun 2017, David Malcolm wrote:
> > How about:
> > 
> > "Warn about unsafe multiple statement macros that appear to be guarded
> > by a clause such as if, else, while, or for, in which only the first
> > statement is actually guarded after the macro is expanded."
> > 
> > or somesuch?
> 
> Yes, I like this.
> 
> On Thu, 8 Jun 2017, Martin Sebor wrote:
> > I don't have strong feelings about the current wording but if it
> > should be tweaked for accuracy I would suggest to use the formal
> > term "controlling expression", similarly to -Wswitch-unreachable.
> 
> That sounds good to me.
> 
> Some comments on the original patch:
> 
>   +Warn about macros expanding to multiple statements in a body of a conditional,
>   +such as @code{if}, @code{else}, @code{for}, or @code{while}.
> 
> "in the body of a $WHATEVER_WE_SHALL_CALL_IT"
 
It now says something other than that, so that mistake is not there anymore.

>   +The can usually be fixed by wrapping the macro in a do-while loop:
> 
> Is there a particular reason for not using an if(1) { } statement?
> 
> Ah, of course, a following else statement would be impacted by that.
> Do we want to note that in the documentation?

I don't think so, we only suggest do {} while (0);.

>   +This warning is enabled by @option{-Wall} in C and C++.
> 
> "for C and C++" instead of "in"?

Other parts of invoke.text use both, so I left that as it was.  I think
both work here.

> I'm curious to see how many issues this is going to find in real-world
> code out there!

Yeah, me too.

	Marek

  reply	other threads:[~2017-06-13 13:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08 16:49 Marek Polacek
2017-06-08 17:24 ` David Malcolm
2017-06-08 18:10   ` Martin Sebor
2017-06-09 22:03     ` Gerald Pfeifer
2017-06-13 13:46       ` Marek Polacek [this message]
2017-07-17  8:15       ` Gerald Pfeifer
2017-07-17  9:26         ` Marek Polacek
2017-06-13 10:05   ` Marek Polacek
2017-06-13 15:29     ` Joseph Myers
2017-06-19 10:01       ` Marek Polacek
2017-06-26  9:40         ` Marek Polacek
2017-06-26 13:13           ` David Malcolm
2017-06-10  0:47 ` Jason Merrill

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=20170613134527.GB3413@redhat.com \
    --to=polacek@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gerald@pfeifer.com \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=msebor@gmail.com \
    --cc=msebor@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).