From: Jakub Jelinek Date: Mon, 6 Feb 2017 20:06:16 +0000 (+0100) Subject: re PR c++/79379 (ICE with #pragma GCC ivdep) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=98e092450153399c1c2b6db5eee6722ebfcb2957;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a318c7fb8b8..0e3e38cef08 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-02-06 Jakub Jelinek + 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. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f9bc518641b..bb45f1e8059 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3313268a639..6737cf46e3c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-02-06 Jakub Jelinek + PR c++/79379 + * g++.dg/cpp1y/constexpr-79379.C: New test. + PR c++/79377 * g++.dg/lookup/pr79377.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-79379.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-79379.C new file mode 100644 index 00000000000..db0981d8b1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-79379.C @@ -0,0 +1,19 @@ +// PR c++/79379 +// { dg-do compile { target c++14 } } +// { dg-options "-O2" } + +template +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, "");