OSDN Git Service

fortran/
authoreedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 30 Oct 2005 22:43:45 +0000 (22:43 +0000)
committereedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 30 Oct 2005 22:43:45 +0000 (22:43 +0000)
2005-10-30  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/18883
        * trans-decl.c (gfc_finish_var_decl): Add decl to the
        current function, rather than the parent.  Make
        assertion accept fake result variables.
        * trans-expr.c (gfc_conv_variable): If the character
        length of an ENTRY isn't set, get the length from
        the master function instead.

testsuite
2005-10-30  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/18883
        * gfortran.dg/char_result_9.f90: New.
        * gfortran.dg/char_result_10.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106254 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 5711cf6..03441c7 100644 (file)
@@ -1,3 +1,13 @@
+2005-10-30  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       PR fortran/18883
+       * trans-decl.c (gfc_finish_var_decl): Add decl to the
+       current function, rather than the parent.  Make
+       assertion accept fake result variables.
+       * trans-expr.c (gfc_conv_variable): If the character
+       length of an ENTRY isn't set, get the length from
+       the master function instead.
+
 2005-10-30  Thomas Koenig  <Thomas.Koenig@online.de>
 
        * gfortran.texi:  Remove reservations about I/O usability.  Document
index ff69954..dce4095 100644 (file)
@@ -469,7 +469,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
      function scope.  */
   if (current_function_decl != NULL_TREE)
     {
-      if (sym->ns->proc_name->backend_decl == current_function_decl)
+      if (sym->ns->proc_name->backend_decl == current_function_decl
+          || sym->result == sym)
        gfc_add_decl_to_function (decl);
       else
        gfc_add_decl_to_parent_function (decl);
@@ -487,7 +488,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   else if (sym->module && !sym->attr.result && !sym->attr.dummy)
     {
       /* TODO: Don't set sym->module for result or dummy variables.  */
-      gcc_assert (current_function_decl == NULL_TREE);
+      gcc_assert (current_function_decl == NULL_TREE || sym->result == sym);
       /* This is the declaration of a module variable.  */
       TREE_PUBLIC (decl) = 1;
       TREE_STATIC (decl) = 1;
index fe5e24b..f911487 100644 (file)
@@ -403,7 +403,12 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr)
   /* For character variables, also get the length.  */
   if (sym->ts.type == BT_CHARACTER)
     {
-      se->string_length = sym->ts.cl->backend_decl;
+      /* If the character length of an entry isn't set, get the length from
+         the master function instead.  */
+      if (sym->attr.entry && !sym->ts.cl->backend_decl)
+        se->string_length = sym->ns->proc_name->ts.cl->backend_decl;
+      else
+        se->string_length = sym->ts.cl->backend_decl;
       gcc_assert (se->string_length);
     }
 
index 26acd54..da223ef 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-28  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       PR fortran/18883
+       * gfortran.dg/char_result_9.f90: New.
+       * gfortran.dg/char_result_10.f90: New.
+
 2005-10-30  Jan Hubicka  <jh@suse.cz>
 
        * g++.dg/tree-ssa/pr24172.C: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/char_result_10.f90 b/gcc/testsuite/gfortran.dg/char_result_10.f90
new file mode 100644 (file)
index 0000000..d14fd38
--- /dev/null
@@ -0,0 +1,36 @@
+! { dg-do compile }
+! PR 18883: Fake result variables of non-constant length, with ENTRY
+function s_to_c(chars)
+    character, pointer :: chars(:)
+    character(len=len(chars)) :: s_to_c, s_to_c_2
+    s_to_c = 'a'
+    return
+entry s_to_c_2(chars)
+    s_to_c_2 = 'b'
+    return
+end function s_to_c
+
+program huj
+
+    implicit none
+    interface
+        function s_to_c(chars)
+            character, pointer :: chars(:)
+            character(len=len(chars)) :: s_to_c
+        end function s_to_c
+
+        function s_to_c_2(chars)
+            character, pointer :: chars(:)
+            character(len=len(chars)) :: s_to_c_2
+        end function s_to_c_2
+    end interface
+
+    character, pointer :: c(:)
+    character(3) :: s
+
+    allocate(c(5))
+    c = (/"a", "b", "c" /)
+    s = s_to_c(c)
+    s = s_to_c_2(c)
+
+end program huj
diff --git a/gcc/testsuite/gfortran.dg/char_result_9.f90 b/gcc/testsuite/gfortran.dg/char_result_9.f90
new file mode 100644 (file)
index 0000000..e32df0e
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! PR 18883: Fake result variables of non-constant length, in module
+module foo
+contains
+    function s_to_c(chars)
+        character, pointer :: chars(:)
+        character(len=len(chars)) :: s_to_c
+        s_to_c = 'a'
+    end function s_to_c
+end module foo
+
+program huj
+
+    use foo
+
+    implicit none
+    character, pointer :: c(:)
+    character(3) :: s
+
+    allocate(c(5))
+    c = (/"a", "b", "c" /)
+    s = s_to_c(c)
+
+end program huj