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: Fix PR 18586


This patch fixes an ICE-on-invalid; the problem was that we had
mismatched push_scope/pop_scope calls.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-11-24  Mark Mitchell  <mark@codesourcery.com>

	PR c++/18586
	* parser.c (cp_parser_init_declarator): Do not pop scope twice.

2004-11-24  Mark Mitchell  <mark@codesourcery.com>

	PR c++/18586
	* g++.dg/template/crash27.C: New test. 

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.279
diff -c -5 -p -r1.279 parser.c
*** cp/parser.c	12 Nov 2004 21:47:07 -0000	1.279
--- cp/parser.c	24 Nov 2004 17:47:17 -0000
*************** cp_parser_init_declarator (cp_parser* pa
*** 10588,10598 ****
    /* For an in-class declaration, use `grokfield' to create the
       declaration.  */
    if (member_p)
      {
        if (pop_p)
! 	pop_scope (scope);
        decl = grokfield (declarator, decl_specifiers,
  			initializer, /*asmspec=*/NULL_TREE,
  			/*attributes=*/NULL_TREE);
        if (decl && TREE_CODE (decl) == FUNCTION_DECL)
  	cp_parser_save_default_args (parser, decl);
--- 10588,10601 ----
    /* For an in-class declaration, use `grokfield' to create the
       declaration.  */
    if (member_p)
      {
        if (pop_p)
! 	{
! 	  pop_scope (scope);
! 	  pop_p = false;
! 	}
        decl = grokfield (declarator, decl_specifiers,
  			initializer, /*asmspec=*/NULL_TREE,
  			/*attributes=*/NULL_TREE);
        if (decl && TREE_CODE (decl) == FUNCTION_DECL)
  	cp_parser_save_default_args (parser, decl);
Index: testsuite/g++.dg/template/crash27.C
===================================================================
RCS file: testsuite/g++.dg/template/crash27.C
diff -N testsuite/g++.dg/template/crash27.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/crash27.C	24 Nov 2004 17:47:23 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/18586
+ template <int> struct A {
+   template <int N> int A<N>::i; // { dg-error "" } 
+ };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]