* [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949)
@ 2017-06-13 17:01 Marek Polacek
2017-06-13 17:11 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2017-06-13 17:01 UTC (permalink / raw)
To: GCC Patches
-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.
--- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949)
2017-06-13 17:01 [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949) Marek Polacek
@ 2017-06-13 17:11 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2017-06-13 17:11 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-13 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13 17:01 [PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949) Marek Polacek
2017-06-13 17:11 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).