C++ PATCH: PR 10527

Mark Mitchell mark@codesourcery.com
Tue Apr 29 20:17:00 GMT 2003


This patch fixes a crash during error reporting; installed on the
mainline and on the branch.

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

2003-04-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10527
	* error.c (dump_expr): Correctly handling of NEW_EXPR.4

2003-04-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10527
	* g++.dg/init/new7.C: New test.

Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.192.2.3
diff -c -5 -p -r1.192.2.3 error.c
*** cp/error.c	18 Feb 2003 14:27:42 -0000	1.192.2.3
--- cp/error.c	29 Apr 2003 20:12:20 -0000
*************** dump_expr (t, flags)
*** 1648,1657 ****
--- 1648,1658 ----
        break;
  
      case NEW_EXPR:
        {
  	tree type = TREE_OPERAND (t, 1);
+ 	tree init = TREE_OPERAND (t, 2);
  	if (NEW_EXPR_USE_GLOBAL (t))
  	  print_scope_operator (scratch_buffer);
  	output_add_string (scratch_buffer, "new ");
  	if (TREE_OPERAND (t, 0))
  	  {
*************** dump_expr (t, flags)
*** 1664,1677 ****
  	    (TREE_OPERAND (type, 0),
  	     build_index_type (fold (build (MINUS_EXPR, integer_type_node,
  					    TREE_OPERAND (type, 1),
  					    integer_one_node))));
  	dump_type (type, flags);
! 	if (TREE_OPERAND (t, 2))
  	  {
  	    print_left_paren (scratch_buffer);
! 	    dump_expr_list (TREE_OPERAND (t, 2), flags);
  	    print_right_paren (scratch_buffer);
  	  }
        }
        break;
  
--- 1665,1685 ----
  	    (TREE_OPERAND (type, 0),
  	     build_index_type (fold (build (MINUS_EXPR, integer_type_node,
  					    TREE_OPERAND (type, 1),
  					    integer_one_node))));
  	dump_type (type, flags);
! 	if (init)
  	  {
  	    print_left_paren (scratch_buffer);
! 	    if (TREE_CODE (init) == TREE_LIST)
! 	      dump_expr_list (init, flags);
! 	    else if (init == void_zero_node)
! 	      /* This representation indicates an empty initializer,
! 		 e.g.: "new int()".  */
! 	      ;
! 	    else
! 	      dump_expr (init, flags);
  	    print_right_paren (scratch_buffer);
  	  }
        }
        break;
  
Index: testsuite/g++.dg/init/new7.C
===================================================================
RCS file: testsuite/g++.dg/init/new7.C
diff -N testsuite/g++.dg/init/new7.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/new7.C	29 Apr 2003 20:12:20 -0000
***************
*** 0 ****
--- 1,7 ----
+ template <class T>
+  struct Foo
+  {};
+  
+  template <class T>
+  void Foo<T>::NON_EXISTENT(int* val = new int()) {} // { dg-error "" }
+  



More information about the Gcc-patches mailing list