c++: avoid duplicate deprecated warning [PR90451]
authorJason Merrill <jason@redhat.com>
Wed, 16 Feb 2022 19:05:39 +0000 (14:05 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 17 Feb 2022 21:22:27 +0000 (16:22 -0500)
commitc352ef0ed90cfc07d494dfec111121bc683e337b
tree0c14058aac3509d668d643c748d6077570a80b0d
parentefbb17db52afd802300c4dcce208fab326ec2915
c++: avoid duplicate deprecated warning [PR90451]

We were getting the deprecated warning twice for the same call because we
called mark_used first in finish_qualified_id_expr and then again in
build_over_call.  Let's not call it the first time; C++17 clarified that a
function is used only when it is selected from an overload set, which
happens later.

Then I had to add a few more uses in places that don't do anything further
with the expression (convert_to_void, finish_decltype_type), and places that
use the expression more unusually (cp_build_addr_expr_1,
convert_nontype_argument).  The new mark_single_function is mostly so
that I only have to put the comment in one place.

PR c++/90451

gcc/cp/ChangeLog:

* decl2.cc (mark_single_function): New.
* cp-tree.h: Declare it.
* typeck.cc (cp_build_addr_expr_1): mark_used when making a PMF.
* semantics.cc (finish_qualified_id_expr): Not here.
(finish_id_expression_1): Or here.
(finish_decltype_type): Call mark_single_function.
* cvt.cc (convert_to_void): And here.
* pt.cc (convert_nontype_argument): And here.
* init.cc (build_offset_ref): Adjust assert.

gcc/testsuite/ChangeLog:

* g++.dg/warn/deprecated-14.C: New test.
* g++.dg/warn/deprecated-15.C: New test.
gcc/cp/cp-tree.h
gcc/cp/cvt.cc
gcc/cp/decl2.cc
gcc/cp/init.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/warn/deprecated-14.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/deprecated-15.C [new file with mode: 0644]