This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70922] -Wparentheses warning should not complain about if-else from macro expansion


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70922

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The warning is about dangling else, which you have in the source.
if (cond)
  for (...)
    if (cond2)
      ...
    else
and while the C/C++ grammar say they bind to the inner-most if, many people
actually mistake this.  Put all of the above into a macro and with Marek's
patch you won't get desirable warning.  Now, you say that if the outer if is
not from a macro or outer macro and the inner else is together with the inner
if from the same macro, we shouldn't warn?  That sounds quite complicated set
of rules.  What if the outer if, inner if and else each comes from a different
macro?

Note, clang and clang++ warn on this as well.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]