This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++14/lambda] Experimental polymorphic lambda patches
- From: Jason Merrill <jason at redhat dot com>
- To: Adam Butcher <adam at jessamine dot co dot uk>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Jul 2013 19:35:24 -0700
- Subject: Re: [C++14/lambda] Experimental polymorphic lambda patches
- References: <1372721221-6201-1-git-send-email-adam at jessamine dot co dot uk>
On 07/01/2013 04:26 PM, Adam Butcher wrote:
I've finally reworked the generic lambda patches I made back in 2009
(http://gcc.1065356.n5.nabble.com/lambda-Latest-experimental-polymorphic-lambda-patches-tt713016.html)
to apply against GCC's mainline.
Great!
Missing features:
- Conversion to function pointer of stateless generic lambdas is
currently unsupported. Currently a warning is generated for all
such lambdas at their definition.
Other issues: (see XXX, FIXME, TODO)
a) Location of implementation.
Let's move all the lambda code into a new lambda.c, semantics.c has
gotten huge.
b) What to do about name mangling?
I think what you have already should do the right thing; for normal
function template instantiations we mangle the uninstantiated type of
the template along with the template arguments, so I think for a generic
lambda just mangling the uninstantiated parameter types is the way to go.
Any comments appreciated. Guidance on implementing the conversion
operator for stateless generic lambdas would be useful. I've made a
few attempts which were lacking!
It seemed to me that N3649's description of the semantics should
translate pretty easily into an implementation. What problems are you
running into?
+ Couldn't figure out a clean way to test for lambda inside
+ check_member_template. */
LAMBDA_TYPE_P (current_class_type) doesn't work?
fn = lambda_function (closure);
+ if (TREE_CODE (fn) == TEMPLATE_DECL)
+ fn = DECL_TEMPLATE_RESULT (fn);
I think you could use STRIP_TEMPLATE before returning from
lambda_function so that we don't need to adjust all the callers to deal
with stripping the template, so instead of
- lambda = BASELINK_FUNCTIONS (lambda);
+ lambda = OVL_CURRENT (BASELINK_FUNCTIONS (lambda));
You could have
lambda = STRIP_TEMPLATE (get_first_fn (lambda));
+ if (TREE_CODE (d) == TEMPLATE_DECL)
+ return d;
Instead of this, let's avoid calling instantiate_decl from
instantiate_class_template_1.
e) Should collect 'auto' parameters during parse and realloc
template parameter list once at the end of the parameter list
rather than incrementally.
I agree, I don't think you need to do anything special while parsing the
parameter list.
Jason