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,committed] Partial fix for PR13092 (more template template argument parsing)


Hi

This patch for 3.4 adjust the code in 'cp_parser_template_argument' to
use 'cp_parser_lookup_name' functionality to build UNBOUND_CLASS_TEMPLATE.
Also a flaw in 'cp_parser_lookup_name' where 'make_unbound_class_template'
may return a TEMPLATE_DECL is fixed.  The added robustness partially fixes
PR13092, turning ice-on-valid-code (which is a regression from 3.3) into 
rejects-valid (GCC 3.3 behavior).

Tested on i686-pc-linux-gnu.  Applied to main trunk as obvious.  Testcase
will be added when PR13092 is completely fixed.

--Kriang


2004-01-03  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/13094
	* parser.c (cp_parser_template_argument): Don't call
	make_unbound_class_template directly.
	(cp_parser_lookup_name): Don't extract TEMPLATE_DECL from
	UNBOUND_CLASS_TEMPLATE tree node.


diff -cp gcc-main-save/gcc/cp/parser.c gcc-main-new/gcc/cp/parser.c
*** gcc-main-save/gcc/cp/parser.c	Fri Jan  2 21:09:35 2004
--- gcc-main-new/gcc/cp/parser.c	Fri Jan  2 21:48:15 2004
*************** cp_parser_template_argument (cp_parser* 
*** 8169,8180 ****
    if (!cp_parser_error_occurred (parser))
      {
        /* Figure out what is being referred to.  */
!       argument = cp_parser_lookup_name_simple (parser, argument);
!       if (template_p)
! 	argument = make_unbound_class_template (TREE_OPERAND (argument, 0),
! 						TREE_OPERAND (argument, 1),
! 						tf_error);
!       else if (TREE_CODE (argument) != TEMPLATE_DECL)
  	cp_parser_error (parser, "expected template-name");
      }
    if (cp_parser_parse_definitely (parser))
--- 8169,8181 ----
    if (!cp_parser_error_occurred (parser))
      {
        /* Figure out what is being referred to.  */
!       argument = cp_parser_lookup_name (parser, argument,
! 					/*is_type=*/false,
! 					/*is_template=*/template_p,
! 					/*is_namespace=*/false,
! 					/*check_dependency=*/true);
!       if (TREE_CODE (argument) != TEMPLATE_DECL
! 	  && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
  	cp_parser_error (parser, "expected template-name");
      }
    if (cp_parser_parse_definitely (parser))
*************** cp_parser_lookup_name (cp_parser *parser
*** 13347,13355 ****
  						  name,
  						  /*complain=*/1));
  	  else if (is_template)
! 	    decl = TYPE_NAME (make_unbound_class_template (parser->scope,
! 							   name,
! 							   /*complain=*/1));
  	  else
  	    decl = build_nt (SCOPE_REF, parser->scope, name);
  	}
--- 13348,13356 ----
  						  name,
  						  /*complain=*/1));
  	  else if (is_template)
! 	    decl = make_unbound_class_template (parser->scope,
! 						name,
! 						/*complain=*/1);
  	  else
  	    decl = build_nt (SCOPE_REF, parser->scope, name);
  	}
*************** cp_parser_lookup_name (cp_parser *parser
*** 13428,13433 ****
--- 13429,13435 ----
    my_friendly_assert (DECL_P (decl) 
  		      || TREE_CODE (decl) == OVERLOAD
  		      || TREE_CODE (decl) == SCOPE_REF
+ 		      || TREE_CODE (decl) == UNBOUND_CLASS_TEMPLATE
  		      || BASELINK_P (decl),
  		      20000619);
  


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