diff options
author | Jason Merrill <jason@redhat.com> | 2023-10-20 12:22:44 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-10-25 11:02:31 -0400 |
commit | 406709b1c7b134a7a05445837f406e98c04f76f0 (patch) | |
tree | d5b4ea97c460c0f7e4d1fa4faf69c41bb97b0388 | |
parent | 678e6c328c77db383431751bcfcf867b02369bd6 (diff) | |
download | gcc-406709b1c7b134a7a05445837f406e98c04f76f0.zip gcc-406709b1c7b134a7a05445837f406e98c04f76f0.tar.gz gcc-406709b1c7b134a7a05445837f406e98c04f76f0.tar.bz2 |
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.
-rw-r--r-- | gcc/cp/cp-gimplify.cc | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 15 |
2 files changed, 16 insertions, 8 deletions
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index 33e9411..9375a11 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -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_) diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index d78005e..bf3bcd1 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -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. |