]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: improve comment
authorJason Merrill <jason@redhat.com>
Fri, 20 Oct 2023 16:22:44 +0000 (12:22 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 25 Oct 2023 15:02:31 +0000 (11:02 -0400)
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.

gcc/cp/cp-gimplify.cc
gcc/cp/cp-tree.def

index 33e9411f10c6e2b8a8b325f5f144a99d065ca94c..9375a116f06c60bb9845d53dd4c7ac9965298a6f 100644 (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_)
index d78005e50b97b7e18599ac6765963e7c13ae2d49..bf3bcd1bf13bd82835342a52a055db869cdbd4ab 100644 (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').
-
-      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.
+      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 (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.