Commit 063700a6 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/85094 (-g with any optimization suppresses -Wduplicated-branches)

	PR c/85094
	* fold-const.c (operand_equal_p): Handle DEBUG_BEGIN_STMT.
	For STATEMENT_LIST, pass down OEP_LEXICOGRAPHIC and maybe
	OEP_NO_HASH_CHECK for recursive call, to avoid exponential
	checking.

	* c-c++-common/Wduplicated-branches-14.c: New test.

From-SVN: r258950
parent 52df8bd9
2018-03-29 Jakub Jelinek <jakub@redhat.com>
PR c/85094
* fold-const.c (operand_equal_p): Handle DEBUG_BEGIN_STMT.
For STATEMENT_LIST, pass down OEP_LEXICOGRAPHIC and maybe
OEP_NO_HASH_CHECK for recursive call, to avoid exponential
checking.
2018-03-28 Peter Bergner <bergner@vnet.ibm.com> 2018-03-28 Peter Bergner <bergner@vnet.ibm.com>
PR target/84912 PR target/84912
......
...@@ -3479,7 +3479,8 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) ...@@ -3479,7 +3479,8 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
if (tsi_end_p (tsi1) && tsi_end_p (tsi2)) if (tsi_end_p (tsi1) && tsi_end_p (tsi2))
return 1; return 1;
if (!operand_equal_p (tsi_stmt (tsi1), tsi_stmt (tsi2), if (!operand_equal_p (tsi_stmt (tsi1), tsi_stmt (tsi2),
OEP_LEXICOGRAPHIC)) flags & (OEP_LEXICOGRAPHIC
| OEP_NO_HASH_CHECK)))
return 0; return 0;
} }
} }
...@@ -3492,6 +3493,10 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) ...@@ -3492,6 +3493,10 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
if (flags & OEP_LEXICOGRAPHIC) if (flags & OEP_LEXICOGRAPHIC)
return OP_SAME_WITH_NULL (0); return OP_SAME_WITH_NULL (0);
return 0; return 0;
case DEBUG_BEGIN_STMT:
if (flags & OEP_LEXICOGRAPHIC)
return 1;
return 0;
default: default:
return 0; return 0;
} }
......
2018-03-29 Jakub Jelinek <jakub@redhat.com>
PR c/85094
* c-c++-common/Wduplicated-branches-14.c: New test.
2018-03-29 Paolo Carlini <paolo.carlini@oracle.com> 2018-03-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84606 PR c++/84606
......
/* PR c/85094 */
/* { dg-do compile } */
/* { dg-options "-O1 -Wduplicated-branches -g" } */
extern int g;
void
foo (int r)
{
if (r < 64)
g -= 48;
else if (r < 80) /* { dg-warning "this condition has identical branches" } */
g -= 64 - 45;
else
g -= 80 - 61;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment