c++: improve comment

It's incorrect to say that the address of an OFFSET_REF is always a
pointer-to-member; if it represents an overload set with both static and
non-static member functions that ends up resolving to a static one, the
address is a normal pointer.  And let's go ahead and mention explicit object
member functions even though the patch hasn't landed yet.

gcc/cp/ChangeLog:

	* cp-tree.def: Improve OFFSET_REF comment.
	* cp-gimplify.cc (cp_fold_immediate): Add to comment.
This commit is contained in:
Jason Merrill 2023-10-20 12:22:44 -04:00
parent 678e6c328c
commit 406709b1c7
2 changed files with 15 additions and 7 deletions

View file

@ -1132,7 +1132,14 @@ cp_fold_immediate (tree *tp, mce_value manifestly_const_eval)
Note: The folding of non-omp cases is something to move into
the middle-end. As for now we have most foldings only on GENERIC
in fold-const, we need to perform this before transformation to
GIMPLE-form. */
GIMPLE-form.
??? This is algorithmically weird because walk_tree works in pre-order, so
we see outer expressions before inner expressions. This isn't as much of an
issue because cp_fold recurses into subexpressions in many cases, but then
walk_tree walks back into those subexpressions again. We avoid the
resulting complexity problem by caching the result of cp_fold, but it's
inelegant. */
static tree
cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)

View file

@ -24,13 +24,14 @@ along with GCC; see the file COPYING3. If not see
/* An OFFSET_REF is used in two situations:
1. An expression of the form `A::m' where `A' is a class and `m' is
a non-static member. In this case, operand 0 will be a TYPE
(corresponding to `A') and operand 1 will be a FIELD_DECL,
BASELINK, or TEMPLATE_ID_EXPR (corresponding to `m').
a non-static member or an overload set. In this case, operand 0
will be a TYPE (corresponding to `A') and operand 1 will be a
FIELD_DECL, BASELINK, or TEMPLATE_ID_EXPR (corresponding to `m').
The expression is a pointer-to-member if its address is taken,
but simply denotes a member of the object if its address is not
taken.
The expression is a pointer-to-member if its address is taken (and
if, after any overload resolution, 'm' does not designate a
static or explicit object member function). It simply denotes a
member of the object if its address is not taken.
This form is only used during the parsing phase; once semantic
analysis has taken place they are eliminated.