From b52a1dfe12a6303c7649f3ff5b8dac6c1001d49a Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 3 Feb 2021 11:58:13 -0500 Subject: [PATCH] c++: Mark member functions as const [PR98951] These member functions look like they could be marked const, since they don't modify any (non-mutable) class members. PR c++/98951 * call.c (struct z_candidate): Mark rewritten and reversed as const. (struct NonPublicField): Mark operator() as const. (struct NonTrivialField): Likewise. --- gcc/cp/call.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 87a7af12796..3068c0f8cfd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -520,8 +520,8 @@ struct z_candidate { /* The flags active in add_candidate. */ int flags; - bool rewritten () { return (flags & LOOKUP_REWRITTEN); } - bool reversed () { return (flags & LOOKUP_REVERSED); } + bool rewritten () const { return (flags & LOOKUP_REWRITTEN); } + bool reversed () const { return (flags & LOOKUP_REVERSED); } }; /* Returns true iff T is a null pointer constant in the sense of @@ -9474,7 +9474,7 @@ first_non_static_field (tree type, Predicate pred) struct NonPublicField { - bool operator() (const_tree t) + bool operator() (const_tree t) const { return DECL_P (t) && (TREE_PRIVATE (t) || TREE_PROTECTED (t)); } @@ -9491,7 +9491,7 @@ first_non_public_field (tree type) struct NonTrivialField { - bool operator() (const_tree t) + bool operator() (const_tree t) const { return !trivial_type_p (DECL_P (t) ? TREE_TYPE (t) : t); } -- 2.30.2