Commit f746a029 by Jason Merrill Committed by Jason Merrill

re PR c++/57391 (ICE compiling AIX math.h caused by PR c++/56930)

	PR c++/57391
	* semantics.c (cxx_eval_constant_expression): Handle FMA_EXPR.
	(cxx_eval_trinary_expression): Rename from cxx_eval_vec_perm_expr.

From-SVN: r199292
parent aea0101d
2013-05-24 Jason Merrill <jason@redhat.com>
PR c++/57391
* semantics.c (cxx_eval_constant_expression): Handle FMA_EXPR.
(cxx_eval_trinary_expression): Rename from cxx_eval_vec_perm_expr.
2013-05-23 Jason Merrill <jason@redhat.com> 2013-05-23 Jason Merrill <jason@redhat.com>
PR c++/57388 PR c++/57388
......
...@@ -7776,37 +7776,32 @@ non_const_var_error (tree r) ...@@ -7776,37 +7776,32 @@ non_const_var_error (tree r)
} }
} }
/* Evaluate VEC_PERM_EXPR (v1, v2, mask). */ /* Subroutine of cxx_eval_constant_expression.
Like cxx_eval_unary_expression, except for trinary expressions. */
static tree static tree
cxx_eval_vec_perm_expr (const constexpr_call *call, tree t, cxx_eval_trinary_expression (const constexpr_call *call, tree t,
bool allow_non_constant, bool addr, bool allow_non_constant, bool addr,
bool *non_constant_p, bool *overflow_p) bool *non_constant_p, bool *overflow_p)
{ {
int i; int i;
tree args[3]; tree args[3];
tree val; tree val;
tree elttype = TREE_TYPE (t);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
args[i] = cxx_eval_constant_expression (call, TREE_OPERAND (t, i), args[i] = cxx_eval_constant_expression (call, TREE_OPERAND (t, i),
allow_non_constant, addr, allow_non_constant, addr,
non_constant_p, overflow_p); non_constant_p, overflow_p);
if (*non_constant_p) VERIFY_CONSTANT (args[i]);
goto fail;
} }
gcc_assert (TREE_CODE (TREE_TYPE (args[0])) == VECTOR_TYPE); val = fold_ternary_loc (EXPR_LOCATION (t), TREE_CODE (t), TREE_TYPE (t),
gcc_assert (TREE_CODE (TREE_TYPE (args[1])) == VECTOR_TYPE);
gcc_assert (TREE_CODE (TREE_TYPE (args[2])) == VECTOR_TYPE);
val = fold_ternary_loc (EXPR_LOCATION (t), VEC_PERM_EXPR, elttype,
args[0], args[1], args[2]); args[0], args[1], args[2]);
if (val != NULL_TREE) if (val == NULL_TREE)
return val; return t;
VERIFY_CONSTANT (val);
fail: return val;
return t;
} }
/* Attempt to reduce the expression T to a constant value. /* Attempt to reduce the expression T to a constant value.
...@@ -8106,9 +8101,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, ...@@ -8106,9 +8101,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case FMA_EXPR:
case VEC_PERM_EXPR: case VEC_PERM_EXPR:
r = cxx_eval_vec_perm_expr (call, t, allow_non_constant, addr, r = cxx_eval_trinary_expression (call, t, allow_non_constant, addr,
non_constant_p, overflow_p); non_constant_p, overflow_p);
break; break;
case CONVERT_EXPR: case CONVERT_EXPR:
......
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