From 7d349dd8e87c7f0bcfd1e03911035b578220c50f Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 26 Aug 2019 14:39:08 +0000 Subject: [PATCH] PR c++/91545 - ICE in constexpr store evaluation. * constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead of DECL_P. * g++.dg/cpp0x/pr91545.C: New test. From-SVN: r274930 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constexpr.c | 2 +- gcc/testsuite/ChangeLog | 9 +++++++-- gcc/testsuite/g++.dg/cpp0x/pr91545.C | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr91545.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 013de12242a..f0eb35c1e4e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-08-26 Marek Polacek + + PR c++/91545 - ICE in constexpr store evaluation. + * constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead + of DECL_P. + 2019-08-24 Nathan Sidwell * class.c (check_for_overrides): Conversion operators need diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index dbd0dc3b445..6c547d6d179 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3849,7 +3849,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, { tree ob = TREE_OPERAND (probe, 0); tree elt = TREE_OPERAND (probe, 1); - if (DECL_P (elt) && DECL_MUTABLE_P (elt)) + if (TREE_CODE (elt) == FIELD_DECL && DECL_MUTABLE_P (elt)) mutable_p = true; if (evaluated && modifying_const_object_p (TREE_CODE (t), probe, mutable_p) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5a2d7bb50e..fab9d338e30 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-26 Marek Polacek + + PR c++/91545 - ICE in constexpr store evaluation. + * g++.dg/cpp0x/pr91545.C: New test. + 2019-08-26 Tejas Joshi * gcc.target/i386/sse4_1-round-roundeven-1.c: New test. @@ -5,8 +10,8 @@ 2019-08-26 Tejas Joshi - * gcc.dg/torture/builtin-round-roundeven.c: New test. - * gcc.dg/torture/builtin-round-roundevenf128.c: Likewise. + * gcc.dg/torture/builtin-round-roundeven.c: New test. + * gcc.dg/torture/builtin-round-roundevenf128.c: Likewise. 2019-08-26 Robin Dapp diff --git a/gcc/testsuite/g++.dg/cpp0x/pr91545.C b/gcc/testsuite/g++.dg/cpp0x/pr91545.C new file mode 100644 index 00000000000..2aa1fa18bd5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr91545.C @@ -0,0 +1,5 @@ +// PR c++/91545 +// { dg-do compile { target c++11 } } + +long a[1]; +int d, e { d && (a[d] = 0) }; -- 2.30.2