This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Annother result variables fix.
- From: Paul Brook <paul at nowt dot org>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>,fortran at gcc dot gnu dot org
- Date: Sat, 11 Oct 2003 22:16:46 +0100
- Subject: [gfortran] Annother result variables fix.
Patch below fixes character type result variables.
Applied to tree-ssa branch.
Paul
2003-10-11 Huang Chun <jiwang@mail.edu.cn>
* trans-types.c (gfc_sym_type): Handle result variables.
2003-10-11 Paul Brook <paul@nowt.org>
* gfortran.fortran-torture/execute/strret.f90: Also test result vars.
diff -urpxCVS clean/tree-ssa/gcc/fortran/trans-types.c gcc/gcc/fortran/
trans-types.c
--- clean/tree-ssa/gcc/fortran/trans-types.c
+++ gcc/gcc/fortran/trans-types.c
@@ -926,7 +926,8 @@ gfc_sym_type (gfc_symbol * sym)
if (sym->ts.type == BT_CHARACTER)
{
if (sym->attr.dimension
- || sym->attr.pointer || sym->attr.allocatable || sym->attr.function)
+ || sym->attr.pointer || sym->attr.allocatable
+ || sym->attr.function || sym->attr.result)
type = build_pointer_type (type);
}
diff -urpxCVS clean/tree-ssa/gcc/testsuite/gfortran.fortran-torture/execute/
strret.f90 gcc/gcc/testsuite/gfortran.fortran-torture/execute/strret.f90
--- clean/tree-ssa/gcc/testsuite/gfortran.fortran-torture/execute/strret.f90
+++ gcc/gcc/testsuite/gfortran.fortran-torture/execute/strret.f90
@@ -1,18 +1,25 @@
! Program to test caracter string return values
-function test()
+function test ()
implicit none
character(len=10) :: test
test = "World"
end function
+function test2 () result (r)
+ implicit none
+ character(len=5) :: r
+ r = "Hello"
+end function
+
program strret
implicit none
character(len=15) :: s
character(len=10) :: test
+ character(len=5) :: test2
- s = test()
+ s = test ()
if (s .ne. "World") call abort
- s = "Hello " // test()
- if (s .ne. "Hello World") call abort
+ s = "Hello " // test ()
+ if (s .ne. test2 () //" World") call abort
end