[cfe-dev] Missing lvalue-to-rvalue cast for first arg of ->* ?
Enea Zaffanella
zaffanella at cs.unipr.it
Thu Jun 30 01:55:21 PDT 2011
When dumping the AST for the following C++ program:
struct B { int mem; };
void foo(B* pb, int B::* pmem) {
pb->mem;
pb->*pmem;
}
it can be seen that the lvalue pointer pd, when used as the first
argument of MemberExpr pb->mem, is subject to an LValueToRValue implicit
cast.
This is not the case when pb is used as the first argument in the
member-pointer operator ->*.
Similarly, lvalue member-pointers (such as pmem) occurring as the second
argument of ->* and .* operators are not subject to LValueToRValue
implicit casts.
Is this difference meant (and why)?
In our experience, the presence of these LValueToRValue casts is very
useful to simplify the logic of custom AST visitors.
Cheers,
Enea.
More information about the cfe-dev
mailing list