public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96468] Warn when an empty while loop could have been a do-while Date: Thu, 06 Aug 2020 00:07:47 +0000 [thread overview] Message-ID: <bug-96468-4-cyk66Cq4Un@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96468-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96468 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |c --- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- Oh. So you're just looking for a simple lexical check to see if a while statement is preceded by a block { } and a warning if it is and (presumably) isn't the result of macro expansion. E.g., issue a warning here: void f (void) { { debug ("in f ()"); } while (!signaled); // warn } but not here (: void f (void) { DEBUG // expands to { debug (...); } while (!signaled); // don't warn } That should be simpler and doable in the front end (so back to C for component) but also seems considerably less useful to me as well as more prone to noise. Front end isn't really my area so I don't expect to work on this but a couple of questions occur to me: should blank lines between the closing curly or the while have any effect on the warnig? If yes as I would expect it starts to feel like it's in the same area as -Wmisleading-indentation. What about other iteration statements -- should those be considered as well? while (condition); // warning? (spurious semicolon) { } for (...; condition; ...); // ditto { }
next prev parent reply other threads:[~2020-08-06 0:07 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-04 17:32 [Bug c/96468] New: " josephcsible at gmail dot com 2020-08-05 7:30 ` [Bug c/96468] " rguenth at gcc dot gnu.org 2020-08-05 14:48 ` msebor at gcc dot gnu.org 2020-08-05 15:03 ` josephcsible at gmail dot com 2020-08-05 15:45 ` [Bug tree-optimization/96468] " msebor at gcc dot gnu.org 2020-08-05 15:56 ` josephcsible at gmail dot com 2020-08-06 0:07 ` msebor at gcc dot gnu.org [this message] 2020-08-06 23:09 ` [Bug c/96468] " egallager 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-96468-4-cyk66Cq4Un@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: linkBe 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).