MEMBER_TYPE and CV qualifiers
Mark Mitchell
mark@codesourcery.com
Sun Jul 17 20:07:00 GMT 2005
Nathan Sidwell wrote:
> I'm looking at holding the CV qualifiers of a member function on the MEMBER_TYPE
> node itself, rather than only on the this pointer argument.
I don't think that's a good idea. The "const" on the member function
really does apply to the type pointed to be the "this" pointer, and it
doesn't have much significance beyond that. (For example, the reason
you can't call a non-const member function on a cost object is just that
you can't pass a "T*" to a function expecting "T const*".)
I can see that -- purely for convenience or efficiency -- it might make
sense to also maintain the cv-qualifiers on the FUNCTION_TYPE itself,
but I'd want to see proof first, as that does mean that we'd have to
keep the two copes in synch, which has historically been a source of bugs.
> this brings up a design issue of what TYPE_MAIN_VARIANT should be of a cv
> qualified member function. Should it be itself (thereby breaking the invariant
> that T_M_V is always unqualified), or should it be the cv unqualified member
> function? Our current behaviour is such that T_M_V of a member function is a
> self reference.
I think that's the right choice. The function type is no more
cv-qualified than any other function type; the only thing that's
cv-qualified is the type pointed to by the first argument.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
More information about the Gcc
mailing list