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] |
On Mon, Nov 15, 2010 at 3:27 PM, Jason Merrill <jason@redhat.com> wrote: > At the standards committee meeting last week I proposed changing > type-specifier-seq to decl-specifier-seq in the range-based for loop > (http://open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1204), and people > agreed. ÂThe change hasn't gone into the WP yet, but I expect it will at the > next meeting. ÂCan you update your patch accordingly? Sure. Actually I was parsing the range-for using cp_parser_decl_specifier_seq and then checking whether it is really a type-specifier-seq. Just removing this check should do the trick. > Looking back, it looks like I didn't mention that I was going to suggest > this; sorry for not keeping you in the loop. No problem. Should I write a testcase for this? I find difficult to write one that looks minimally realistic: for (struct S {} *s : { (S*)NULL, (S*)NULL, (S*)NULL }) ; or: for (struct S {} s : { S(), S(), S() }) ; or even: for (struct S { S(int xx):x(xx){} int x; } s : { 1, 2, 3 }) ; are correct but mostly useless. By the way, now that we are changing things, I find somewhat surprising that the name of the declarator is mandatory. Let's say that I want to repeat a identical code twice: for (int x : {0, 0}) { /*...*/ } But this issues: warning: variable 'x' set but not used [-Wunused-but-set-variable]. Shouldn't this be allowed, then? for (int : {0, 0}) { /*...*/ } Or a more useful example: struct Work { Work(const char *name) { /* do something useful */ } }; const char *names[] = {"foo", "bar", "goo"}; /*...*/ for (Work : names) ; Regards. Rodrigo
Attachment:
range-for3.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |