This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949)
- 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>
- Date: Tue, 13 Jun 2017 19:11:05 +0200
- Subject: Re: [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2BB3733458C
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2BB3733458C
- References: <20170613170110.GC3413@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jun 13, 2017 at 07:01:11PM +0200, Marek Polacek wrote:
> -Wduplicated-branches can crash on a weird ObjC testcase that we haven't
> managed to reduce, so no testcase attached. On that testcase, we end up
> calling do_warn_duplicated_branches with null COND_EXPR_THEN, and the code
> wasn't prepared to handle that. The fix is trivial. Eric G. verified that
> this indeed fixes the ICE (thanks).
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2017-06-13 Marek Polacek <polacek@redhat.com>
>
> PR objc/80949
> * c-warn.c (do_warn_duplicated_branches): Return if any of the
> branches is null.
Ok, thanks.
> --- gcc/c-family/c-warn.c
> +++ gcc/c-family/c-warn.c
> @@ -2354,8 +2354,8 @@ do_warn_duplicated_branches (tree expr)
> tree thenb = COND_EXPR_THEN (expr);
> tree elseb = COND_EXPR_ELSE (expr);
>
> - /* Don't bother if there's no else branch. */
> - if (elseb == NULL_TREE)
> + /* Don't bother if any of the branches is missing. */
> + if (thenb == NULL_TREE || elseb == NULL_TREE)
> return;
>
> /* And don't warn for empty statements. */
>
> Marek
Jakub