Re: [PATCH] PR c++/66735 lambda capture by reference

2017-01-04 Thread Jason Merrill
OK. On Wed, Jan 4, 2017 at 8:52 AM, Nathan Sidwell wrote: > On 01/04/2017 12:36 AM, Jason Merrill wrote: >> >> On 01/03/2017 08:57 AM, Nathan Sidwell wrote: > > >>> + type = auto_node; >>> + if (by_reference_p) > > >>> + type = build_reference_type (type); >>> + by_reference_p

Re: [PATCH] PR c++/66735 lambda capture by reference

2017-01-04 Thread Nathan Sidwell
On 01/04/2017 12:36 AM, Jason Merrill wrote: On 01/03/2017 08:57 AM, Nathan Sidwell wrote: + type = auto_node; + if (by_reference_p) + type = build_reference_type (type); + by_reference_p = false; ^^^ here + if (!is_this && by_reference_p) +type = build_reference_

Re: [PATCH] PR c++/66735 lambda capture by reference

2017-01-03 Thread Jason Merrill
On 01/03/2017 08:57 AM, Nathan Sidwell wrote: else if (!is_this && explicit_init_p) { - type = make_auto (); - type = do_auto_deduction (type, expr, type); + tree auto_node = make_auto (); + + type = auto_node; + if (by_reference_p) + { + /* Add the

[PATCH] PR c++/66735 lambda capture by reference

2017-01-03 Thread Nathan Sidwell
This patch fixes 66735, where we lose cv qualifiers on an explicit lambda capture by reference: [&r = ] () {...} The problem is the partitioning between lambda_capture_field_type and add_capture, where the latter is responsible for adding the referenceness. That leaves auto deduction cluel