From 5e2be41f37d39b91e27c4d129a5861cfe80809ec Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 19 Jul 2008 20:29:18 +0200 Subject: [PATCH] re PR fortran/36795 (crash with character allocatable array argument) 2008-07-19 Tobias Burnus PR fortran/36795 * matchexp.c (gfc_get_parentheses): Remove obsolete workaround, which caused the generation of wrong code. 2008-07-19 Tobias Burnus PR fortran/36795 * char_expr_1.f90: New. * char_expr_2.f90: New. From-SVN: r137986 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/matchexp.c | 7 ------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/char_expr_1.f90 | 20 ++++++++++++++++++++ gcc/testsuite/gfortran.dg/char_expr_2.f90 | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/char_expr_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/char_expr_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index dc592eda24b..9325c45ff23 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-07-19 Tobias Burnus + + PR fortran/36795 + * matchexp.c (gfc_get_parentheses): Remove obsolete workaround, + which caused the generation of wrong code. + 2008-07-19 Tobias Burnus PR fortran/36342 diff --git a/gcc/fortran/matchexp.c b/gcc/fortran/matchexp.c index a53c69bc71b..0092f4086bb 100644 --- a/gcc/fortran/matchexp.c +++ b/gcc/fortran/matchexp.c @@ -130,13 +130,6 @@ gfc_get_parentheses (gfc_expr *e) { gfc_expr *e2; - /* This is a temporary fix, awaiting the patch for various - other character problems. The resolution and translation - of substrings and concatenations are so kludged up that - putting parentheses around them breaks everything. */ - if (e->ts.type == BT_CHARACTER && e->ref) - return e; - e2 = gfc_get_expr(); e2->expr_type = EXPR_OP; e2->ts = e->ts; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a487a3e74c9..6ac4232c026 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-07-19 Tobias Burnus + + PR fortran/36795 + * char_expr_1.f90: New. + * char_expr_2.f90: New. + 2008-07-19 Olivier Hainque * gcc.dg/mallign.c: New test. diff --git a/gcc/testsuite/gfortran.dg/char_expr_1.f90 b/gcc/testsuite/gfortran.dg/char_expr_1.f90 new file mode 100644 index 00000000000..ba0e1f23350 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_expr_1.f90 @@ -0,0 +1,20 @@ +! { dg-do "run" } +! PR fortran/36795 +! "(str)" (= an expression) was regarded as "str" (= a variable) +! and thus when yy was deallocated so was xx. Result: An invalid +! memory access. +! +program main + implicit none + character (len=10), allocatable :: str(:) + allocate (str(1)) + str(1) = "dog" + if (size(str) /= 1 .or. str(1) /= "dog") call abort() +contains + subroutine foo(xx,yy) + character (len=*), intent(in) :: xx(:) + character (len=*), intent(out), allocatable :: yy(:) + allocate (yy(size(xx))) + yy = xx + end subroutine foo +end program main diff --git a/gcc/testsuite/gfortran.dg/char_expr_2.f90 b/gcc/testsuite/gfortran.dg/char_expr_2.f90 new file mode 100644 index 00000000000..86499eb454c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_expr_2.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/36803 +! PR fortran/36795 +! +! "(n)" was simplified to the EXPR_VARIABLE "n" +! and thus "(n)" was judged as definable. +! +interface + subroutine foo(x) + character, intent(out) :: x(:) ! or INTENT(INOUT) + end subroutine foo +end interface +character :: n(5) +call foo( (n) ) ! { dg-error "must be definable" } +end -- 2.30.2