This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: MEMBER_TYPE and CV qualifiers
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Sun, 17 Jul 2005 13:07:01 -0700
- Subject: Re: MEMBER_TYPE and CV qualifiers
- References: <42DA7B60.2070405@codesourcery.com>
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