OK. On Mon, Aug 26, 2019 at 9:35 AM Marek Polacek <pola...@redhat.com> wrote:
> Now that DECL_MUTABLE_P checks that it got a FIELD_DECL node, One Does Not > Simply Check DECL_P. For an ARRAY_REF, "elt" can be a VAR_DECL. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > 2019-08-26 Marek Polacek <pola...@redhat.com> > > 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. > > diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c > index dbd0dc3b445..6c547d6d179 100644 > --- gcc/cp/constexpr.c > +++ 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 gcc/testsuite/g++.dg/cpp0x/pr91545.C > gcc/testsuite/g++.dg/cpp0x/pr91545.C > new file mode 100644 > index 00000000000..2aa1fa18bd5 > --- /dev/null > +++ 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) }; >