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 9172


This patch fixes a crash in the new parser on an invalid use of the
typename keyword.  (And removes one unncessary declaration from
cp-tree.h)

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

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2003-01-12  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (get_arglist_len_in_bytes): Remove.

	PR c++/9264
	* parser.c (cp_parser_elaborated_type_specifier): Handle erroneous
	typeame types more robustly.

2003-01-12  Mark Mitchell  <mark@codesourcery.com>

	PR c++/9172
	* g++.dg/parse/typename1.C: New file.

Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.797
diff -c -5 -p -r1.797 cp-tree.h
*** cp/cp-tree.h	10 Jan 2003 20:49:29 -0000	1.797
--- cp/cp-tree.h	13 Jan 2003 00:03:39 -0000
*************** extern GTY(()) operator_name_info_t oper
*** 3579,3589 ****
  extern GTY(()) operator_name_info_t assignment_operator_name_info
    [(int) LAST_CPLUS_TREE_CODE];
  
  /* in call.c */
  extern bool check_dtor_name (tree, tree);
- extern int get_arglist_len_in_bytes		(tree);
  
  extern tree build_vfield_ref			(tree, tree);
  extern tree build_scoped_method_call (tree, tree, tree, tree);
  extern tree build_conditional_expr		(tree, tree, tree);
  extern tree build_addr_func (tree);
--- 3579,3588 ----
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.27
diff -c -5 -p -r1.27 parser.c
*** cp/parser.c	10 Jan 2003 22:57:04 -0000	1.27
--- cp/parser.c	13 Jan 2003 00:03:41 -0000
*************** cp_parser_elaborated_type_specifier (par
*** 9010,9023 ****
    /* Look for the `::' operator.  */
    cp_parser_global_scope_opt (parser, 
  			      /*current_scope_valid_p=*/false);
    /* Look for the nested-name-specifier.  */
    if (tag_type == typename_type)
!     cp_parser_nested_name_specifier (parser,
! 				     /*typename_keyword_p=*/true,
! 				     /*check_dependency_p=*/true,
! 				     /*type_p=*/true);
    else
      /* Even though `typename' is not present, the proposed resolution
         to Core Issue 180 says that in `class A<T>::B', `B' should be
         considered a type-name, even if `A<T>' is dependent.  */
      cp_parser_nested_name_specifier_opt (parser,
--- 9010,9027 ----
    /* Look for the `::' operator.  */
    cp_parser_global_scope_opt (parser, 
  			      /*current_scope_valid_p=*/false);
    /* Look for the nested-name-specifier.  */
    if (tag_type == typename_type)
!     {
!       if (cp_parser_nested_name_specifier (parser,
! 					   /*typename_keyword_p=*/true,
! 					   /*check_dependency_p=*/true,
! 					   /*type_p=*/true) 
! 	  == error_mark_node)
! 	return error_mark_node;
!     }
    else
      /* Even though `typename' is not present, the proposed resolution
         to Core Issue 180 says that in `class A<T>::B', `B' should be
         considered a type-name, even if `A<T>' is dependent.  */
      cp_parser_nested_name_specifier_opt (parser,
Index: testsuite/g++.dg/parse/typename1.C
===================================================================
RCS file: testsuite/g++.dg/parse/typename1.C
diff -N testsuite/g++.dg/parse/typename1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/typename1.C	13 Jan 2003 00:03:44 -0000
***************
*** 0 ****
--- 1,5 ----
+ template <class baz>
+ struct bar
+ {
+   typedef typename baz::typename rebind<int> foo; // { dg-error "" }
+ };


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