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.
This commit is contained in:
Marek Polacek 2021-02-03 11:58:13 -05:00
parent 5c62e4f255
commit b52a1dfe12

View File

@ -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);
}