]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: bogus warning with value init of const pmf [PR92752]
authorPatrick Palka <ppalka@redhat.com>
Fri, 28 Jan 2022 20:41:15 +0000 (15:41 -0500)
committerPatrick Palka <ppalka@redhat.com>
Fri, 30 Jun 2023 04:03:15 +0000 (00:03 -0400)
commit8c12c47d0c5c40df6e5eeb8625d4708c8a42dbe0
tree28292b4535dcd1e7deddbbeadd3122f240265b67
parentad42219766d0e67bede2c9bd94c98082cde42518
c++: bogus warning with value init of const pmf [PR92752]

Here we're emitting a -Wignored-qualifiers warning for an intermediate
compiler-generated cast of nullptr to 'method-type* const' as part of
value initialization of a const pmf.  This patch suppresses the warning
by instead casting to the corresponding unqualified type.

PR c++/92752

gcc/cp/ChangeLog:

* typeck.c (build_ptrmemfunc): Cast a nullptr constant to the
unqualified pointer type not the qualified one.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wignored-qualifiers2.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit e971990cbda091b4caf5e1a5bded5121068934e4)
gcc/cp/typeck.c
gcc/testsuite/g++.dg/warn/Wignored-qualifiers2.C [new file with mode: 0644]