aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-04-26 17:30:39 -0400
committerPatrick Palka <ppalka@redhat.com>2021-04-26 17:30:39 -0400
commit0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3 (patch)
treef24c2aca76b5e6a869254f9dd4633b83a3524fec /gcc/tree-ssa-alias.c
parentbd7ebe9da745a62184052dd1b15f4dd10fbdc9f4 (diff)
downloadgcc-0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3.zip
gcc-0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3.tar.gz
gcc-0120cd9382728fdc99d4cfdcb72cd0f55aca2ce3.tar.bz2
c++: constexpr pointer indirection with negative offset [PR100209]
During constexpr evaluation, a base-to-derived conversion may yield an expression like (Derived*)(&D.2217.D.2106 p+ -4) where D.2217 is the derived object and D.2106 is the base. But cxx_fold_indirect_ref doesn't know how to resolve an INDIRECT_REF thereof to just D.2217, because it doesn't handle POINTER_PLUS_EXPR of a COMPONENT_REF with negative offset well: when the offset N is positive, it knows that '&x p+ N' is equivalent to '&x.f p+ (N - bytepos(f))', but it doesn't know about the reverse transformation, that '&x.f p+ N' is equivalent to '&x p+ (N + bytepos(f))' when N is negative, which is important for resolving such base-to-derived conversions and for accessing subobjects backwards. This patch teaches cxx_fold_indirect_ref this reverse transformation. gcc/cp/ChangeLog: PR c++/100209 * constexpr.c (cxx_fold_indirect_ref): Try to canonicalize the object/offset pair for a POINTER_PLUS_EXPR of a COMPONENT_REF with a negative offset into one whose offset is nonnegative before calling cxx_fold_indirect_ref_1. gcc/testsuite/ChangeLog: PR c++/100209 * g++.dg/cpp1y/constexpr-base1.C: New test. * g++.dg/cpp1y/constexpr-ptrsub1.C: New test.
Diffstat (limited to 'gcc/tree-ssa-alias.c')
0 files changed, 0 insertions, 0 deletions