Commit 5bf69d74 by Marek Polacek Committed by Marek Polacek

re PR middle-end/79536 (ICE in fold_binary_loc, at fold-const.c:9060)

	PR middle-end/79536
	* fold-const.c (fold_negate_expr_1): Renamed from fold_negate_expr.
	(fold_negate_expr): New wrapper.

	* gcc.dg/torture/pr79536.c: New test.

From-SVN: r245526
parent 6a011df2
2017-02-17 Marek Polacek <polacek@redhat.com>
PR middle-end/79536
* fold-const.c (fold_negate_expr_1): Renamed from fold_negate_expr.
(fold_negate_expr): New wrapper.
2017-02-16 Sandra Loosemore <sandra@codesourcery.com> 2017-02-16 Sandra Loosemore <sandra@codesourcery.com>
* doc/invoke.texi (C++ Dialect Options) [-Wno-non-template-friend]: * doc/invoke.texi (C++ Dialect Options) [-Wno-non-template-friend]:
......
...@@ -139,6 +139,7 @@ static tree fold_relational_const (enum tree_code, tree, tree, tree); ...@@ -139,6 +139,7 @@ static tree fold_relational_const (enum tree_code, tree, tree, tree);
static tree fold_convert_const (enum tree_code, tree, tree); static tree fold_convert_const (enum tree_code, tree, tree);
static tree fold_view_convert_expr (tree, tree); static tree fold_view_convert_expr (tree, tree);
static bool vec_cst_ctor_to_array (tree, tree *); static bool vec_cst_ctor_to_array (tree, tree *);
static tree fold_negate_expr (location_t, tree);
/* Return EXPR_LOCATION of T if it is not UNKNOWN_LOCATION. /* Return EXPR_LOCATION of T if it is not UNKNOWN_LOCATION.
...@@ -522,7 +523,7 @@ negate_expr_p (tree t) ...@@ -522,7 +523,7 @@ negate_expr_p (tree t)
returned. */ returned. */
static tree static tree
fold_negate_expr (location_t loc, tree t) fold_negate_expr_1 (location_t loc, tree t)
{ {
tree type = TREE_TYPE (t); tree type = TREE_TYPE (t);
tree tem; tree tem;
...@@ -715,6 +716,19 @@ fold_negate_expr (location_t loc, tree t) ...@@ -715,6 +716,19 @@ fold_negate_expr (location_t loc, tree t)
return NULL_TREE; return NULL_TREE;
} }
/* A wrapper for fold_negate_expr_1. */
static tree
fold_negate_expr (location_t loc, tree t)
{
tree type = TREE_TYPE (t);
STRIP_SIGN_NOPS (t);
tree tem = fold_negate_expr_1 (loc, t);
if (tem == NULL_TREE)
return NULL_TREE;
return fold_convert_loc (loc, type, tem);
}
/* Like fold_negate_expr, but return a NEGATE_EXPR tree, if T can not be /* Like fold_negate_expr, but return a NEGATE_EXPR tree, if T can not be
negated in a simpler way. Also allow for T to be NULL_TREE, in which case negated in a simpler way. Also allow for T to be NULL_TREE, in which case
return NULL_TREE. */ return NULL_TREE. */
......
2017-02-17 Marek Polacek <polacek@redhat.com>
PR middle-end/79536
* gcc.dg/torture/pr79536.c: New test.
2017-02-16 Alan Modra <amodra@gmail.com> 2017-02-16 Alan Modra <amodra@gmail.com>
* gcc.c-torture/execute/pr79286.c: New. * gcc.c-torture/execute/pr79286.c: New.
......
/* { dg-do compile } */
typedef int A;
int
fn1 (A x, A y)
{
if ((x + (x - y) * 1i) != -(-x + (y - x) * 1i))
return 1;
return 0;
}
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