This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ICE with -Wduplicated-branches (PR objc/80949)


-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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]