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]

[Patch, fortran] PR24655 and PR24755 - segfaults in test for statement function recursion.


:ADDPATCH fortran:

This patch is self explanatory and I propose to commit it tonight as
"obvious" unless there are any objections.  I will bubblestrap, regtest and
commit from Linux!

Regtested on Cygwin_NT/PIV - OK for mainline and 4.0?

Paul T

2005-11-10  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24655
	PR fortran/24755
	* match.c (recursive_stmt_fcn): Add checks that symtree exists for
the
	expression to weed out inline intrinsic functions and parameters.

2005-11-10  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24655
	PR fortran/24755
	* gfortran.dg/recursive_statement_functions.f90: Add statement
functions
	using inline intrinsic functions and parameters to test that they no
	longer seg-fault.

Index: gcc/gcc/fortran/match.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/match.c,v
retrieving revision 1.47
diff -c -p -r1.47 match.c
*** gcc/gcc/fortran/match.c	17 Oct 2005 20:52:36 -0000	1.47
--- gcc/gcc/fortran/match.c	10 Nov 2005 10:29:15 -0000
*************** recursive_stmt_fcn (gfc_expr *e, gfc_sym
*** 2721,2727 ****
  	  if (sym->name == arg->name
  		|| recursive_stmt_fcn (arg->expr, sym))
  	    return true;
! 	}
  
        /* Check the name before testing for nested recursion!  */
        if (sym->name == e->symtree->n.sym->name)
--- 2721,2730 ----
  	  if (sym->name == arg->name
  		|| recursive_stmt_fcn (arg->expr, sym))
  	    return true;
! 	}
! 
!       if (e->symtree == NULL)
! 	return false;
  
        /* Check the name before testing for nested recursion!  */
        if (sym->name == e->symtree->n.sym->name)
*************** recursive_stmt_fcn (gfc_expr *e, gfc_sym
*** 2736,2742 ****
        break;
  
      case EXPR_VARIABLE:
!       if (sym->name == e->symtree->n.sym->name)
  	return true;
        break;
  
--- 2739,2745 ----
        break;
  
      case EXPR_VARIABLE:
!       if (e->symtree && sym->name == e->symtree->n.sym->name)
  	return true;
        break;
  
Index: gcc/gcc/testsuite/gfortran.dg/recursive_statement_functions.f90
===================================================================
RCS file:
/cvsroot/gcc/gcc/gcc/testsuite/gfortran.dg/recursive_statement_functions.f90
,v
retrieving revision 1.1
diff -c -p -r1.1 recursive_statement_functions.f90
*** gcc/gcc/testsuite/gfortran.dg/recursive_statement_functions.f90	17
Oct 2005 20:52:37 -0000	1.1
--- gcc/gcc/testsuite/gfortran.dg/recursive_statement_functions.f90	10
Nov 2005 10:28:58 -0000
***************
*** 1,16 ****
  ! { dg-do compile }
  ! PR20866 - A statement function cannot be recursive.
  ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
!   INTEGER :: i, st1, st2, st3
    REAL :: x, z(2,2)
!   character*8 :: ch
  !
  ! Test check for recursion via other statement functions, string
  ! length references, function actual arguments and array index
  ! references.
!   st1(i)=len(ch(st2(1):8))
!   st2(i)=max (st3(1), 4)
!   st3(i)=2 + cos (z(st1 (1), i)) ! { dg-error "is recursive" }
!   write(6,*) st1(1)
    END
  
--- 1,32 ----
  ! { dg-do compile }
  ! PR20866 - A statement function cannot be recursive.
  ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
! !
! ! Modified 20051110 to check that regressions PR24655 and PR24755
! ! are fixed. Thanks to pavarini@pv.infn.it and tdeutsch@cea.fr for
! ! the tests.
! !
!   INTEGER :: i, st1, st2, st3, lambda, n
    REAL :: x, z(2,2)
!   character(8) :: ch
!   real(8)   :: fi, arg, sigma, dshpfunc
!   real(8), parameter :: one=1d0
  !
  ! Test check for recursion via other statement functions, string
  ! length references, function actual arguments and array index
  ! references.
! !
!   st1 (i) = len (ch(st2 (1):8))
!   st2 (i) = max (st3 (1), 4)
!   st3 (i) = 2 + cos (z(st1 (1), i)) ! { dg-error "is recursive" }
! !
! ! Test the two regressions.
! !
!   fi (n) = n *one
!   dshpfunc (arg)=-lambda/sigma*(arg/sigma)**(lambda-1)*exp
(-(arg/sigma)**lambda)
! !
! ! References to each statement function.
! !
!   write(6,*) st1 (1), fi (2), dshpfunc (1.0_8)
    END
  


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