]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/56385 ([OOP] ICE with allocatable function result in a procedure-pointe...
authorJanus Weil <janus@gcc.gnu.org>
Sat, 23 Feb 2013 14:40:49 +0000 (15:40 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Sat, 23 Feb 2013 14:40:49 +0000 (15:40 +0100)
2013-02-23  Janus Weil  <janus@gcc.gnu.org>

PR fortran/56385
* trans-array.c (structure_alloc_comps): Handle procedure-pointer
components with allocatable result.

2013-02-23  Janus Weil  <janus@gcc.gnu.org>

PR fortran/56385
* gfortran.dg/proc_ptr_comp_37.f90: New.

From-SVN: r196237

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

index 417106ef44860e5f0b8cc2fb477144ab2a4ee918..72af533d760d657a1ca2aaf18594dbda74279a1a 100644 (file)
@@ -1,3 +1,9 @@
+2013-02-23  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/56385
+       * trans-array.c (structure_alloc_comps): Handle procedure-pointer
+       components with allocatable result.
+
 2013-02-15  Tobias Burnus  <burnus@net-b.de>
            Mikael Morin  <mikael@gcc.gnu.org>
 
index c3e993415ce9acc1373e2439508f7f3732f4356e..c76cd115cb0ae65d7249268ee2b34c09eda6eebb 100644 (file)
@@ -6560,7 +6560,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
              gfc_add_expr_to_block (&fnblock, tmp);
            }
 
-         if (c->attr.allocatable && c->attr.dimension)
+         if (c->attr.allocatable && c->attr.dimension && !c->attr.proc_pointer)
            {
              comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
                                      decl, cdecl, NULL_TREE);
@@ -6659,7 +6659,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
                                  cdecl, NULL_TREE);
          dcmp = fold_convert (TREE_TYPE (comp), dcmp);
 
-         if (c->attr.allocatable && !cmp_has_alloc_comps)
+         if (c->attr.allocatable && !c->attr.proc_pointer
+             && !cmp_has_alloc_comps)
            {
              rank = c->as ? c->as->rank : 0;
              tmp = gfc_duplicate_allocatable (dcmp, comp, ctype, rank);
index 7e7942dc424d8bfbfe40be3325ddd761e70b36e3..d4aef859ef9185c5574d362ef5e6253b4a456694 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-23  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/56385
+       * gfortran.dg/proc_ptr_comp_37.f90: New.
+
 2013-02-15  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/56318
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_37.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_37.f90
new file mode 100644 (file)
index 0000000..9695b96
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do compile }
+!
+! PR 56385: [4.6/4.7/4.8 Regression] [OOP] ICE with allocatable function result in a procedure-pointer component
+!
+! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com>
+
+  implicit none
+  
+  type :: TGeometricShape
+  end type
+
+  type :: TVolumeSourceBody
+    class(TGeometricShape), allocatable :: GeometricShape
+    procedure(scalar_flux_interface), pointer :: get_scalar_flux
+  end type
+
+  abstract interface
+    function scalar_flux_interface(self) result(res)
+      import
+      real, allocatable :: res(:)
+      class(TVolumeSourceBody), intent(in) :: self
+    end function
+  end interface
+
+end