This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++14/lambda] Experimental polymorphic lambda patches


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]