re PR fortran/15129 (assumed size characters passed to subroutines incorrect)
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Thu, 15 Jul 2004 18:43:50 +0000 (20:43 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Thu, 15 Jul 2004 18:43:50 +0000 (20:43 +0200)
fortran/
PR fortran/15129
* trans-decl.c (gfc_build_function_decl): Create a new chardecl
for every assumed length character dummy argument.

testsuite/
PR fortran/15129
* gfortran.dg/pr15129.f90: New test.

From-SVN: r84769

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr15129.f90 [new file with mode: 0644]

index 78c2537dea2e409196c0a665c0950cd5c6dee8c2..2667cb83160beb65f335e139fd97c8d331bb26c4 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/15129
+       * trans-decl.c (gfc_build_function_decl): Create a new chardecl
+       for every assumed length character dummy argument.
+
 2004-07-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/15324
index 24087c07b88fde8b6492c40e7e81b8f17dbc2fc7..f7cfd9785ca703829544bb957891acb32b19aadc 100644 (file)
@@ -1180,7 +1180,25 @@ gfc_build_function_decl (gfc_symbol * sym)
           if (!f->sym->ts.cl->length)
            {
              TREE_USED (length) = 1;
-             f->sym->ts.cl->backend_decl = length;
+             if (!f->sym->ts.cl->backend_decl)
+               f->sym->ts.cl->backend_decl = length;
+             else
+               {
+                 /* there is already another variable using this
+                    gfc_charlen node, build a new one for this variable
+                    and chain it into the list of gfc_charlens.
+                    This happens for e.g. in the case
+                    CHARACTER(*)::c1,c2
+                    since CHARACTER declarations on the same line share
+                    the same gfc_charlen node.  */
+                 gfc_charlen *cl;
+                 
+                 cl = gfc_get_charlen ();
+                 cl->backend_decl = length;
+                 cl->next = f->sym->ts.cl->next;
+                 f->sym->ts.cl->next = cl;
+                 f->sym->ts.cl = cl;
+               }
            }
 
           parm = TREE_CHAIN (parm);
index 69cd43e3afc654be1f168c70b4b89197c2c733cb..bab21110c6d0e7870e53140bc02b65c5581b7ebe 100644 (file)
@@ -3,6 +3,9 @@
        PR fortran/15324
        * gfortran.dg/pr15324.f90: New test.
 
+       PR fortran/15129
+       * gfortran.dg/pr15129.f90: New test.
+
 2004-07-14  Mike Stump  <mrs@apple.com>
 
        * gcc.dg/20020426-2.c: Improve type safety wrt unsignedness.
diff --git a/gcc/testsuite/gfortran.dg/pr15129.f90 b/gcc/testsuite/gfortran.dg/pr15129.f90
new file mode 100644 (file)
index 0000000..f9a277c
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do run }
+! PR 15129: we used to share the character length between A and B in the 
+! subroutine.
+CHARACTER*10 A
+CHARACTER*8 B
+A = 'gfortran'
+B = 'rocks!'
+CALL T(A,B)
+contains
+SUBROUTINE T(A,B)
+CHARACTER*(*) A,B
+if(len(a)/=10) call abort()
+if(len(b)/=8) call abort()
+END SUBROUTINE
+end