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]

[C++ Patch] PR 29731


Hi,

this extends the fix to the second testcase. Tested x86_64-linux.

Ok for mainline?

Paolo.

//////////////////
/cp
2007-09-03  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-03  Paolo Carlini  <pcarlini@suse.de>

	PR c++/29731
	* g++.dg/parse/template24.C: New.
Index: testsuite/g++.dg/parse/template24.C
===================================================================
*** testsuite/g++.dg/parse/template24.C	(revision 0)
--- testsuite/g++.dg/parse/template24.C	(revision 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" } */
+ }
Index: cp/parser.c
===================================================================
*** cp/parser.c	(revision 128024)
--- cp/parser.c	(working copy)
*************** cp_parser_primary_expression (cp_parser 
*** 3166,3174 ****
  		 int i = ({ int j = 3; j + 1; });
  
  	       at class or namespace scope.  */
! 	    if (!parser->in_function_body)
  	      {
! 		error ("statement-expressions are allowed only inside functions");
  		cp_parser_skip_to_end_of_block_or_statement (parser);
  		expr = error_mark_node;
  	      }
--- 3166,3176 ----
  		 int i = ({ int j = 3; j + 1; });
  
  	       at class or namespace scope.  */
! 	    if (!parser->in_function_body
! 		|| parser->in_template_argument_list_p)
  	      {
! 		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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]