From: Jakub Jelinek Date: Fri, 28 Nov 2025 09:59:35 +0000 (+0100) Subject: c++: Remove PMF special cases from cxx_get_alias_set [PR119969] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0367efb112795290831bbc3eff181707fdfcc52c;p=thirdparty%2Fgcc.git c++: Remove PMF special cases from cxx_get_alias_set [PR119969] The use of 0 alias set for PMF * types seems to break modref for some reason, but because PMFs are canonicalized, there should be no reason to special case the alias set of PMF or PMF * anymore. 2025-11-27 Jakub Jelinek PR c++/119969 * cp-objcp-common.cc (cxx_get_alias_set): Remove special cases for TYPE_PTRMEMFUNC_P and INDIRECT_TYPE_P for TYPE_PTRMEMFUNC_P. * g++.dg/torture/pr119969.C: New test. --- diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index c7e88cb7bfe..859c7d69746 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -180,12 +180,6 @@ cxx_get_alias_set (tree t) complete type. */ return get_alias_set (TYPE_CONTEXT (t)); - /* Punt on PMFs until we canonicalize functions properly. */ - if (TYPE_PTRMEMFUNC_P (t) - || (INDIRECT_TYPE_P (t) - && TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))) - return 0; - return c_common_get_alias_set (t); } diff --git a/gcc/testsuite/g++.dg/torture/pr119969.C b/gcc/testsuite/g++.dg/torture/pr119969.C new file mode 100644 index 00000000000..25a4053c3f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr119969.C @@ -0,0 +1,46 @@ +// PR c++/119969 +// { dg-do run } + +struct S {}; +using PMF = void (S::*)(); +using Block = PMF[16]; +using BlockPtr = Block*; + +struct IteratorImp { + Block** d_blockPtr_p; + PMF* d_value_p; + + void operator++(); + PMF& operator*() const { return *d_value_p; } +}; + +void IteratorImp::operator++() { + int offset = 1 + (d_value_p - **d_blockPtr_p); + d_blockPtr_p += offset / 16; + d_value_p = **d_blockPtr_p + (offset % 16); +} + +struct iterator { + IteratorImp d_imp; +}; + +struct D { + Block* d_blockPtrs[1]; + Block d_block; + PMF* d_start_p; +}; + +D mX; + +void privateInit(int numElements) { + mX.d_blockPtrs[0] = &mX.d_block; + mX.d_start_p = mX.d_block + (numElements + 7); +} + +int main() { + privateInit(0); + iterator cbgn = {{mX.d_blockPtrs, mX.d_block + 7}}; + auto clast = cbgn; + ++clast.d_imp; + if (&*cbgn.d_imp == &*clast.d_imp) return 1; +}