Bug 79566 - [6 Regression] elaborated-type-specifier incorrectly rejected in range-based for
Summary: [6 Regression] elaborated-type-specifier incorrectly rejected in range-based for
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.3.1
: P2 normal
Target Milestone: 6.4
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2017-02-17 00:39 UTC by Jonathan Wakely
Modified: 2017-04-12 21:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.4.1, 7.0
Known to fail: 6.3.0
Last reconfirmed: 2017-02-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2017-02-17 00:39:46 UTC
struct X {
  struct Y { };

  Y* begin();
  Y* end();
};

void f()
{
  X x;
  for (struct X::Y& y : x)
    ;
}

This is valid, but GCC 6 and 7 say:

for.cc:11:8: error: types may not be defined in a for-range-declaration [-fpermissive]
   for (struct X::Y& y : x)
        ^~~~~~
Comment 1 Jason Merrill 2017-02-20 06:06:29 UTC
Author: jason
Date: Mon Feb 20 06:05:54 2017
New Revision: 245591

URL: https://gcc.gnu.org/viewcvs?rev=245591&root=gcc&view=rev
Log:
	PR c++/79566 - elaborated-type-specifier in range for

	* parser.c (cp_parser_simple_declaration): Fix check for type
	definition.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/range-for34.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
Comment 2 Jason Merrill 2017-02-20 07:04:25 UTC
Fixed on trunk so far.
Comment 3 Jason Merrill 2017-04-12 19:23:22 UTC
Author: jason
Date: Wed Apr 12 19:22:50 2017
New Revision: 246887

URL: https://gcc.gnu.org/viewcvs?rev=246887&root=gcc&view=rev
Log:
	PR c++/79566 - elaborated-type-specifier in range for

	* parser.c (cp_parser_simple_declaration): Fix check for type
	definition.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/range-for34.C
Modified:
    branches/gcc-6-branch/gcc/cp/ChangeLog
    branches/gcc-6-branch/gcc/cp/parser.c
Comment 4 Jason Merrill 2017-04-12 21:35:07 UTC
Fixed for 6.4.