aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-02-16 14:05:39 -0500
committerJason Merrill <jason@redhat.com>2022-02-17 16:22:27 -0500
commitc352ef0ed90cfc07d494dfec111121bc683e337b (patch)
tree0c14058aac3509d668d643c748d6077570a80b0d /gcc/cp/init.cc
parentefbb17db52afd802300c4dcce208fab326ec2915 (diff)
downloadgcc-c352ef0ed90cfc07d494dfec111121bc683e337b.zip
gcc-c352ef0ed90cfc07d494dfec111121bc683e337b.tar.gz
gcc-c352ef0ed90cfc07d494dfec111121bc683e337b.tar.bz2
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.
Diffstat (limited to 'gcc/cp/init.cc')
-rw-r--r--gcc/cp/init.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index fcb255f..545d904 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -2362,8 +2362,9 @@ build_offset_ref (tree type, tree member, bool address_p,
return error_mark_node;
gcc_assert (DECL_P (member) || BASELINK_P (member));
- /* Callers should call mark_used before this point. */
- gcc_assert (!DECL_P (member) || TREE_USED (member));
+ /* Callers should call mark_used before this point, except for functions. */
+ gcc_assert (!DECL_P (member) || TREE_USED (member)
+ || TREE_CODE (member) == FUNCTION_DECL);
type = TYPE_MAIN_VARIANT (type);
if (!COMPLETE_OR_OPEN_TYPE_P (complete_type (type)))