C++ PATCH: PR 9639

Mark Mitchell mark@codesourcery.com
Mon Mar 17 17:43:00 GMT 2003


This patch fixes PR 9639, a crash in the new parser.

Tested on i686-pc-linux-gnu, applied on the mainline.

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

2003-03-17  Mark Mitchell  <mark@codesourcery.com>

	PR c++/9639
	* g++.dg/parse/crash1.C: New test. 

2003-03-17  Mark Mitchell  <mark@codesourcery.com>

	PR c++/9639
	* parser.c (cp_parser_declarator_id): Clear parser->scope.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.52
diff -c -5 -p -r1.52 parser.c
*** cp/parser.c	16 Mar 2003 14:36:43 -0000	1.52
--- cp/parser.c	17 Mar 2003 17:27:17 -0000
*************** cp_parser_declarator_id (cp_parser* pars
*** 10422,10432 ****
  					   /*check_dependency_p=*/false,
  					   /*template_p=*/NULL);
    /* If the name was qualified, create a SCOPE_REF to represent 
       that.  */
    if (parser->scope)
!     id_expression = build_nt (SCOPE_REF, parser->scope, id_expression);
  
    return id_expression;
  }
  
  /* Parse a type-id.
--- 10422,10435 ----
  					   /*check_dependency_p=*/false,
  					   /*template_p=*/NULL);
    /* If the name was qualified, create a SCOPE_REF to represent 
       that.  */
    if (parser->scope)
!     {
!       id_expression = build_nt (SCOPE_REF, parser->scope, id_expression);
!       parser->scope = NULL_TREE;
!     }
  
    return id_expression;
  }
  
  /* Parse a type-id.
Index: testsuite/g++.dg/parse/crash1.C
===================================================================
RCS file: testsuite/g++.dg/parse/crash1.C
diff -N testsuite/g++.dg/parse/crash1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/crash1.C	17 Mar 2003 17:34:09 -0000
***************
*** 0 ****
--- 1 ----
+ struct s { s(std::b o) { } }; // { dg-error "" }



More information about the Gcc-patches mailing list