diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-02-06 21:06:16 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-02-06 21:06:16 +0100 |
commit | 98e092450153399c1c2b6db5eee6722ebfcb2957 (patch) | |
tree | 3b1dd3984991418cf6e2eb795cd0cc4ccb5679a3 /gcc | |
parent | e8b0383c1324a80e554e9e0401dc5830c700bb0e (diff) | |
download | gcc-98e092450153399c1c2b6db5eee6722ebfcb2957.zip gcc-98e092450153399c1c2b6db5eee6722ebfcb2957.tar.gz gcc-98e092450153399c1c2b6db5eee6722ebfcb2957.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-79379.C | 19 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a318c7f..0e3e38c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 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. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f9bc5186..bb45f1e 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 3313268..6737cf4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 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. 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 0000000..db0981d --- /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 <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, ""); |