[cfe-dev] (Unexpected) Method type

Abramo Bagnara abramobagnara at tin.it
Fri Jan 8 16:18:15 PST 2010

Analyzing the AST generated for a simple program I've seen a weird
thing: the type of non static methods have the same structure of
ordinary functions.

I've also built a small test case that show this:

$ cat aaa.cc
struct c {
  void h();
  void (*f())() {
    return &h;

$ gcc -c aaa.cc
aaa.cc: In member function ‘void (* c::f())()’:
aaa.cc:4: error: ISO C++ forbids taking the address of an unqualified or
parenthesized non-static member function to form a pointer to member
function.  Say ‘&c::h’
aaa.cc:4: error: cannot convert ‘void (c::*)()’ to ‘void (*)()’ in return
$ ~/llvm/Debug/bin/clang -W -Wall -c aaa.cc

Apart clang behaviour reported above (that I suppose it's definitely a
bug) the choice to not have a MethodType (or MemberFunctionType)
different from FunctionProtoType is deliberate or it's something that
should be saned?

More information about the cfe-dev mailing list