This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70922] -Wparentheses warning should not complain about if-else from macro expansion
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 May 2016 18:40:50 +0000
- Subject: [Bug c++/70922] -Wparentheses warning should not complain about if-else from macro expansion
- Auto-submitted: auto-generated
- References: <bug-70922-4 at http dot gcc dot gnu dot org/bugzilla/>
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.