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
  { }

Reply via email to