diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/template24.C | 8 |
4 files changed, 23 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ab7cb5ffea4..2d261e7381b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-09-05 Paolo Carlini <pcarlini@suse.de> + + PR c++/29731 (again) + * parser.c (cp_parser_primary_expression): Return error_mark_node + when a statement-expression is found in a template-argument list. + 2007-09-04 Jason Merrill <jason@redhat.com> PR c++/31419 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d39721e78fb..9f967177351 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3166,9 +3166,11 @@ cp_parser_primary_expression (cp_parser *parser, int i = ({ int j = 3; j + 1; }); at class or namespace scope. */ - if (!parser->in_function_body) + if (!parser->in_function_body + || parser->in_template_argument_list_p) { - error ("statement-expressions are allowed only inside functions"); + error ("statement-expressions are not allowed outside " + "functions nor in template-argument lists"); cp_parser_skip_to_end_of_block_or_statement (parser); expr = error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ae76e319e0..aa4306bcb41 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-09-05 Paolo Carlini <pcarlini@suse.de> + + PR c++/29731 + * g++.dg/parse/template24.C: New. + 2007-09-04 Andrew Pinski <andrew_pinski@playstation.sony.com> * g++.dg/other/spu2vmx-1.C: New test. diff --git a/gcc/testsuite/g++.dg/parse/template24.C b/gcc/testsuite/g++.dg/parse/template24.C new file mode 100644 index 00000000000..33d9d4cfd5a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template24.C @@ -0,0 +1,8 @@ +/* PR c++/29731. This used to ICE in uses_template_parms. */ + +template<int> struct A {}; + +void foo() +{ + A<({})> a; /* { dg-error "forbids braced-groups within expressions|statement-expressions|template argument 1 is invalid|invalid type" } */ +} |