]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/42597 (ICE with procedure pointer initialized to null())
authorTobias Burnus <burnus@net-b.de>
Thu, 7 Jan 2010 08:12:10 +0000 (09:12 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 7 Jan 2010 08:12:10 +0000 (09:12 +0100)
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/42597
        * gfortran.dg/proc_ptr_26.f90: New test.

From-SVN: r155688

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 43a3af2fe19c3096c3f616233cb44be93fcc654c..dc3aa9718b1328390cd6e5ce40af6804ad11d13c 100644 (file)
@@ -1,3 +1,9 @@
+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
index cf9bef31d93770869e6040680dc88417eca45c74..612c6f6129699c88e5c06e7312366d6cb6aa067f 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 6e0a9038ba8b63fb24aeb78df3910d5c04f94746..459dde397fff58cb85b32ec00ac919d6c5c8d955 100644 (file)
@@ -1,3 +1,8 @@
+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
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" } }