-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 <pola...@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