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 PR10347 (a regression)


Hi

This patch fixes an ICE in type_dependent_expression_p when
it is presented with an array new expression (NEW_EXPR with
operand 1 being a TREE_LIST).  Such NEW_EXPR is created in
build_new when the array new is in a template.

Tested on i686-pc-linux-gnu with no regressions.  OK for
main trunk?

--Kriang


2003-04-15  Kriang Lerdsuwanakij  <lerdsuwa at users dot sourceforge dot net>

	PR c++/10347
	* pt.c (type_dependent_expression_p): Handle array new.

2003-04-15  Kriang Lerdsuwanakij  <lerdsuwa at users dot sourceforge dot net>

	PR c++/10347
	g++.dg/template/dependent-name1.C: New test.

diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Tue Apr 15 20:11:20 2003
--- gcc-main-new/gcc/cp/pt.c	Tue Apr 15 19:12:24 2003
*************** type_dependent_expression_p (expression)
*** 11569,11575 ****
       by the expression.  */
    else if (TREE_CODE (expression) == NEW_EXPR
  	   || TREE_CODE (expression) == VEC_NEW_EXPR)
!     return dependent_type_p (TREE_OPERAND (expression, 1));
  
    if (TREE_CODE (expression) == FUNCTION_DECL
        && DECL_LANG_SPECIFIC (expression)
--- 11569,11588 ----
       by the expression.  */
    else if (TREE_CODE (expression) == NEW_EXPR
  	   || TREE_CODE (expression) == VEC_NEW_EXPR)
!     {
!       /* For NEW_EXPR tree nodes created inside a template, either
! 	 the object type itself or a TREE_LIST may appear as the
! 	 operand 1.  */
!       tree type = TREE_OPERAND (expression, 1);
!       if (TREE_CODE (type) == TREE_LIST)
! 	/* This is an array type.  We need to check array dimensions
! 	   as well.  */
! 	return dependent_type_p (TREE_VALUE (TREE_PURPOSE (type)))
! 	       || value_dependent_expression_p
! 		    (TREE_OPERAND (TREE_VALUE (type), 1));
!       else
! 	return dependent_type_p (type);
!     }
  
    if (TREE_CODE (expression) == FUNCTION_DECL
        && DECL_LANG_SPECIFIC (expression)
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/dependent-name1.C gcc-main-new/gcc/testsuite/g++.dg/template/dependent-name1.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/dependent-name1.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/dependent-name1.C	Tue Apr 15 19:16:15 2003
***************
*** 0 ****
--- 1,11 ----
+ // { dg-do compile }
+ 
+ // Origin: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
+ 
+ // PR c++/10347: Dependent type checking of array new expression
+ 
+ void bar (int *);
+     
+ template <int> void foo() {
+   bar(new int[1]);
+ }


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