[cfe-dev] Unusual cast kinds

Nikola Smiljanic popizdeh at gmail.com
Sat Jan 5 03:51:50 PST 2013


The comment in SemaCast.cpp says that the second kind deals with C++
5.2.10p9:

  *An rvalue of type "pointer to member of X of type T1" can be explicitly
converted to an rvalue of type "pointer to member of Y of type T2" if T1
and T2 are both function types or both object types.*

This is the code that I tried

class X {
public:
  int a;
};

class Y {
public:
  int b;
};

int main() {
  int X::*xptr = &X::a;
  int Y::*yptr = reinterpret_cast<int Y::*>(xptr);
}


On Sat, Jan 5, 2013 at 9:24 PM, Kim Gräsman <kim.grasman at gmail.com> wrote:
> Hi all,
>
> In IWYU [1], we traverse the AST trying to deduce if the use of a
> symbol requires a full declaration or if a forward declaration is
> sufficient.
>
> One of the things we're looking at are cast-expressions, and there are
> two kinds we currently don't cover:
>
>  CK_BuiltinFnToFnPtr
>  CK_ReinterpretMemberPointer
>
> The docstrings for them don't give examples of what they might look
> like, and I'm having trouble coming up with representative examples.
> Can anyone help? And maybe add examples to the docstrings for these
> two kinds?
>
> Thanks!
>
> - Kim
>
> [1] http://code.google.com/p/include-what-you-use/
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130105/636dd4e3/attachment.html>


More information about the cfe-dev mailing list