Message ID | 20210203173158.22292-1-polacek@redhat.com |
---|---|
State | New |
Headers | show |
Series | c++: Mark member functions as const [PR98951] | expand |
On 2/3/21 12:31 PM, Marek Polacek wrote: > These member functions look like they could be marked const, since > they don't modify any (non-mutable) class members. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK, I guess this is trivial enough for stage4. > 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); > } > > base-commit: 530203d6e3244c25eda4124f0fa5756ca9a5683e >
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); }