This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C PATCH to overhaul warning about dangling else (PR c/70436)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Wed, 13 Apr 2016 16:16:40 +0200
- Subject: Re: C PATCH to overhaul warning about dangling else (PR c/70436)
- Authentication-results: sourceware.org; auth=none
- References: <20160413141402 dot GS28445 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Apr 13, 2016 at 04:14:03PM +0200, Marek Polacek wrote:
> I said I'd take care of the C FE part of this PR, so here it is.
>
> As this PR shows, our dangling else warning regressed in such a way that we
> weren't warning about cases such as
>
> if (A)
> for (;;)
> if (B)
> bar ();
> else
> baz ();
>
> The problem was that we were setting FIRST_IF only when an "if" was immediately
> followed by an RID_IF token.
>
> I revamped the warning so that it follows what the C++ FE does (i.e. passing
> IF_P bools here and there) and it seems to work quite well. I didn't mean to
> tackle the OMP bits but I bet it would be just a matter of passing IF_P
> somewhere.
I'll look at the OMP bits both for C and C++ once/if this is committed.
Jakub