Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-23 Thread Jakub Jelinek
On Wed, May 23, 2018 at 02:49:09PM -0400, Marek Polacek wrote: > > Could you please add some testcases that would test the handling of > > structured bindings in these new forms of range for, like: > > for (int i = 0; auto [ x, y ] : z) > > but perhaps for completeness also in the init-stmt and per

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-23 Thread Marek Polacek
On Wed, May 23, 2018 at 06:45:41PM +0200, Jakub Jelinek wrote: > On Wed, May 23, 2018 at 10:45:43AM -0400, Marek Polacek wrote: > > 2018-05-23 Marek Polacek > > > > Implement P0614R1, Range-based for statements with initializer. > > * parser.c (cp_parser_range_based_for_with_init_p): Ne

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-23 Thread Jakub Jelinek
On Wed, May 23, 2018 at 10:45:43AM -0400, Marek Polacek wrote: > 2018-05-23 Marek Polacek > > Implement P0614R1, Range-based for statements with initializer. > * parser.c (cp_parser_range_based_for_with_init_p): New. > (cp_parser_init_statement): Use it. Parse the optional in

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-23 Thread Jason Merrill
OK. On Wed, May 23, 2018 at 10:45 AM, Marek Polacek wrote: > On Tue, May 22, 2018 at 09:46:10PM -0400, Jason Merrill wrote: >> On Tue, May 22, 2018 at 7:25 PM, Marek Polacek wrote: >> > On Mon, May 21, 2018 at 09:51:44PM -0400, Jason Merrill wrote: >> >> On Mon, May 21, 2018 at 7:34 PM, Marek Po

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-23 Thread Marek Polacek
On Tue, May 22, 2018 at 09:46:10PM -0400, Jason Merrill wrote: > On Tue, May 22, 2018 at 7:25 PM, Marek Polacek wrote: > > On Mon, May 21, 2018 at 09:51:44PM -0400, Jason Merrill wrote: > >> On Mon, May 21, 2018 at 7:34 PM, Marek Polacek wrote: > >> > The previous version of this patch got confus

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-22 Thread Jason Merrill
On Tue, May 22, 2018 at 7:25 PM, Marek Polacek wrote: > On Mon, May 21, 2018 at 09:51:44PM -0400, Jason Merrill wrote: >> On Mon, May 21, 2018 at 7:34 PM, Marek Polacek wrote: >> > The previous version of this patch got confused by >> > >> > for (int i = 0; n > 0 ? true : false; i++) >> > /

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-22 Thread Marek Polacek
On Mon, May 21, 2018 at 09:51:44PM -0400, Jason Merrill wrote: > On Mon, May 21, 2018 at 7:34 PM, Marek Polacek wrote: > > The previous version of this patch got confused by > > > > for (int i = 0; n > 0 ? true : false; i++) > > // ... > > > > because even though we see a ; followed by a :,

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-21 Thread Jason Merrill
On Mon, May 21, 2018 at 7:34 PM, Marek Polacek wrote: > The previous version of this patch got confused by > > for (int i = 0; n > 0 ? true : false; i++) > // ... > > because even though we see a ; followed by a :, it's not a range-based for > with > an initializer. I find it very strange

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer

2018-05-21 Thread Jason Merrill
OK. On Mon, May 21, 2018 at 3:50 PM, Marek Polacek wrote: > This is my attempt to implement P0614R1, a C++20 feature whereby we may now > use > an init-statement in a range-based for loop like this: > > for (int i = bar (); const auto &x : a) > // ... > > The somewhat tricky part was to di

Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer

2018-05-21 Thread Marek Polacek
Actually, scratch this. I found an issue with the current patch. Sorry. On Mon, May 21, 2018 at 03:50:05PM -0400, Marek Polacek wrote: > This is my attempt to implement P0614R1, a C++20 feature whereby we may now > use > an init-statement in a range-based for loop like this: ... Marek