OSDN Git Service

2010-01-07 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jan 2010 08:12:10 +0000 (08:12 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jan 2010 08:12:10 +0000 (08:12 +0000)
        PR fortran/42597
        * trans-decl.c (get_proc_pointer_decl): Fix call to
        gfc_conv_initializer for array-valued proc-pointer funcs.

2010-01-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/42597
        * gfortran.dg/proc_ptr_26.f90: New test.

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

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

index 43a3af2..dc3aa97 100644 (file)
@@ -1,5 +1,11 @@
 2010-01-07  Tobias Burnus  <burnus@net-b.de>
 
+       PR fortran/42597
+       * trans-decl.c (get_proc_pointer_decl): Fix call to
+       gfc_conv_initializer for array-valued proc-pointer funcs.
+
+2010-01-07  Tobias Burnus  <burnus@net-b.de>
+
        PR fortran/41872
        * trans-decl.c (gfc_trans_deferred_vars): Don't initialize
        allocatable scalars with SAVE attribute.
index cf9bef3..612c6f6 100644 (file)
@@ -1349,7 +1349,9 @@ get_proc_pointer_decl (gfc_symbol *sym)
     {
       /* Add static initializer.  */
       DECL_INITIAL (decl) = gfc_conv_initializer (sym->value, &sym->ts,
-         TREE_TYPE (decl), sym->attr.dimension, sym->attr.proc_pointer);
+         TREE_TYPE (decl),
+         sym->attr.proc_pointer ? false : sym->attr.dimension,
+         sym->attr.proc_pointer);
     }
 
   attributes = add_attributes_to_decl (sym->attr, NULL_TREE);
index 6e0a903..459dde3 100644 (file)
@@ -1,5 +1,10 @@
 2010-01-07  Tobias Burnus  <burnus@net-b.de>
 
+       PR fortran/42597
+       * gfortran.dg/proc_ptr_26.f90: New test.
+
+2010-01-07  Tobias Burnus  <burnus@net-b.de>
+
        PR fortran/41872
        * gfortran.dg/allocatable_scalar_7.f90: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_26.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_26.f90
new file mode 100644 (file)
index 0000000..044f0a4
--- /dev/null
@@ -0,0 +1,31 @@
+! { dg-do run }
+!
+! PR fortran/42597
+!
+! Contributed by mrestelli@gmail.com
+!
+
+module mod_a
+ implicit none
+
+ abstract interface
+  pure function intf(x) result(y)
+   real, intent(in) :: x(:,:)
+   real :: y(size(x,1),size(x,1),size(x,2))
+  end function intf
+ end interface
+
+ procedure(intf), pointer :: p_fun => null()
+end module mod_a
+
+program main
+  use mod_a
+  implicit none
+
+  procedure(intf), pointer :: p_fun2 => null()
+
+  if (associated(p_fun) .or. associated(p_fun2)) &
+    call abort ()
+end program main
+
+! { dg-final { cleanup-modules "mod_a" } }