Commit 98e09245 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/79379 (ICE with #pragma GCC ivdep)

	PR c++/79379
	* constexpr.c (cxx_eval_constant_expression): Handle ANNOTATE_EXPR.
	(potential_constant_expression_1): Likewise.

	* g++.dg/cpp1y/constexpr-79379.C: New test.

From-SVN: r245220
parent e8b0383c
2017-02-06 Jakub Jelinek <jakub@redhat.com>
PR c++/79379
* constexpr.c (cxx_eval_constant_expression): Handle ANNOTATE_EXPR.
(potential_constant_expression_1): Likewise.
PR c++/79377
* tree.c (build_min_non_dep_op_overload): For POST{INC,DEC}REMENT_EXPR
allow one fewer than expected arguments if flag_permissive.
......
......@@ -4518,6 +4518,14 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
*non_constant_p = true;
return t;
case ANNOTATE_EXPR:
gcc_assert (tree_to_uhwi (TREE_OPERAND (t, 1)) == annot_expr_ivdep_kind);
r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0),
lval,
non_constant_p, overflow_p,
jump_target);
break;
default:
if (STATEMENT_CODE_P (TREE_CODE (t)))
{
......@@ -5689,6 +5697,10 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
return false;
}
case ANNOTATE_EXPR:
gcc_assert (tree_to_uhwi (TREE_OPERAND (t, 1)) == annot_expr_ivdep_kind);
return RECUR (TREE_OPERAND (t, 0), rval);
default:
if (objc_is_property_ref (t))
return false;
......
2017-02-06 Jakub Jelinek <jakub@redhat.com>
PR c++/79379
* g++.dg/cpp1y/constexpr-79379.C: New test.
PR c++/79377
* g++.dg/lookup/pr79377.C: New test.
......
// PR c++/79379
// { dg-do compile { target c++14 } }
// { dg-options "-O2" }
template <int N>
constexpr int
foo (int x)
{
int q[64] = { 0 }, r = 0;
#pragma GCC ivdep
for (int i = 0; i < x; ++i)
q[i] += 2;
for (int i = 0; i < x; ++i)
r += q[i];
return r + N;
}
constexpr int a = foo<0> (17);
static_assert (a == 34, "");
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