PR c++/91548 - fix detecting modifying const objects for ARRAY_REF.
authorMarek Polacek <polacek@redhat.com>
Tue, 29 Oct 2019 20:34:43 +0000 (20:34 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 29 Oct 2019 20:34:43 +0000 (20:34 +0000)
commit0f1848002a137f3cac5026c5a3af6e16ceabe552
tree4af514ce33b47850b73ec43906ac4a386d66cae7
parent6cd96bad607c5d6a2302e97ab6f749edb85b82ed
PR c++/91548 - fix detecting modifying const objects for ARRAY_REF.

This fixes a bogus "modifying a const object" error for an array that actually
isn't declared const.  The problem was how I handled ARRAY_REFs here; we
shouldn't look at the ARRAY_REF itself, but at the array its accessing.

* constexpr.c (cxx_eval_store_expression): Don't call
modifying_const_object_p for ARRAY_REF.

* g++.dg/cpp1y/constexpr-tracking-const15.C: New test.
* g++.dg/cpp1y/constexpr-tracking-const16.C: New test.
* g++.dg/cpp1z/constexpr-tracking-const1.C: New test.

From-SVN: r277591
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const15.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const16.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-tracking-const1.C [new file with mode: 0644]