OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2007 09:31:54 +0000 (09:31 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2007 09:31:54 +0000 (09:31 +0000)
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.

/testsuite
2007-09-05  Paolo Carlini  <pcarlini@suse.de>

PR c++/29731
* g++.dg/parse/template24.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128124 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/template24.C [new file with mode: 0644]

index ab7cb5f..2d261e7 100644 (file)
@@ -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
index d39721e..9f96717 100644 (file)
@@ -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;
              }
index 3ae76e3..aa4306b 100644 (file)
@@ -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 (file)
index 0000000..33d9d4c
--- /dev/null
@@ -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" } */
+}