aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-01-28 15:41:15 -0500
committerPatrick Palka <ppalka@redhat.com>2022-01-28 15:41:15 -0500
commite971990cbda091b4caf5e1a5bded5121068934e4 (patch)
tree3a330d67c266772bd86aba928f7fe768ddd5379b /gcc/cp/typeck.cc
parent3a5fdf986dc6ebb6e244087b462132590ad0a184 (diff)
downloadgcc-e971990cbda091b4caf5e1a5bded5121068934e4.zip
gcc-e971990cbda091b4caf5e1a5bded5121068934e4.tar.gz
gcc-e971990cbda091b4caf5e1a5bded5121068934e4.tar.bz2
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.cc (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>
Diffstat (limited to 'gcc/cp/typeck.cc')
-rw-r--r--gcc/cp/typeck.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 11c9d8a..50d04c1 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -9593,7 +9593,9 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
/* Handle null pointer to member function conversions. */
if (null_ptr_cst_p (pfn))
{
- pfn = cp_build_c_cast (input_location, type, pfn, complain);
+ pfn = cp_build_c_cast (input_location,
+ TYPE_PTRMEMFUNC_FN_TYPE_RAW (to_type),
+ pfn, complain);
return build_ptrmemfunc1 (to_type,
integer_zero_node,
pfn);