Bug 47184 - [C++0x] initialization construct interpreted as function declaration‏‏
Summary: [C++0x] initialization construct interpreted as function declaration‏‏
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-05 18:36 UTC by Nathan Ridge
Modified: 2011-05-26 13:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-25 15:42:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge 2011-01-05 18:36:07 UTC
For the following code:

struct S
{
    int a;
    float b;
};
struct T
{
    T(S s) {}
};
int main()
{
    T t(S{1, 0.1}); // ERROR HERE
}

gcc 4.6 trunk gives the following errors (with the --std=c++0x option):

decl.cpp: In function 'int main()':
decl.cpp:14:10: error: expected ')' before '{' token
decl.cpp:14:10: error: a function-definition is not allowed here before '{' token
decl.cpp:14:18: error: expected primary-expression before ')' token
decl.cpp:14:18: error: expected ';' before ')' token

It seems gcc is interpreting the statement as a function declaration.

I think this is valid C++0x.
Comment 1 Jason Merrill 2011-05-25 19:50:52 UTC
Author: jason
Date: Wed May 25 19:50:49 2011
New Revision: 174225

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174225
Log:
	PR c++/47184
	* parser.c (cp_parser_parameter_declaration): Recognize
	list-initialization.
	(cp_parser_direct_declarator): Check for the closing
	paren before parsing definitely.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist51.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-25 20:29:42 UTC
Author: jason
Date: Wed May 25 20:29:39 2011
New Revision: 174232

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174232
Log:
	PR c++/47184
	* parser.c (cp_parser_parameter_declaration): Recognize
	list-initialization.
	(cp_parser_direct_declarator): Check for the closing
	paren before parsing definitely.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/initlist51.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/parser.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-26 13:44:35 UTC
Fixed for 4.6.1.
Comment 4 Jason Merrill 2011-05-26 13:48:25 UTC
...and actually change status.