[c++] Another question about demangler output
Daniel Jacobowitz
drow@mvista.com
Sun Dec 7 00:03:00 GMT 2003
Consider this program:
template<typename B> class BB { public: BB() { }
typedef int (*foot)(void);
operator foot () { return 0; }
};
BB<int> obj;
int foo()
{
return ((int (*)(void)) obj) != 0;
}
One symbol generated by this program is _ZN2BBIiEcvPFivEEv, which demangles
as:
BB<int>::operator int (*)()()
But that output is quite annoying for me, because it's nothing like legal
C++, as far as I have been able to tell. But I can't find a way to express
that type without using an intermediate typedef.
The reason this bugs me is that I've been writing a fairly dumb "parser" for
things which can appear in symbol names, with the goal of creating a
canonical form for such names for GDB's use. The problem is in some ways
easier and in some ways harder than parsing C++; we don't need to
differentiate between various possible meanings for identifiers, but at the
same time we _can't_ differentiate between them. I've found no reasonable
way for it to figure out what "A::operator int (*)()()" means.
Am I right that this can't be expressed in C++ without using an intermediate
type? If I am right, I'm not sure what to do. If I'm wrong, we can correct
the demangler.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
More information about the Gcc
mailing list