re PR fortran/51082 ([F03] Wrong result for a pointer to a proc-pointer component)
authorJanus Weil <janus@gcc.gnu.org>
Sun, 15 Apr 2012 11:47:49 +0000 (13:47 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Sun, 15 Apr 2012 11:47:49 +0000 (13:47 +0200)
2012-04-15  Janus Weil  <janus@gcc.gnu.org>

PR fortran/51082
* trans-expr.c (gfc_conv_expr_reference): Check if the expression is a
simple function call (or a more involved PPC reference).

2012-04-15  Janus Weil  <janus@gcc.gnu.org>

PR fortran/51082
* gfortran.dg/proc_ptr_comp_34.f90: New test case.

From-SVN: r186465

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

index 9bb46ac..4db00bb 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-15  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/51082
+       * trans-expr.c (gfc_conv_expr_reference): Check if the expression is a
+       simple function call (or a more involved PPC reference).
+
 2012-04-15  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52916
index 036b55b..cd48d5a 100644 (file)
@@ -5650,7 +5650,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
       && ((expr->value.function.esym
           && expr->value.function.esym->result->attr.pointer
           && !expr->value.function.esym->result->attr.dimension)
-         || (!expr->value.function.esym
+         || (!expr->value.function.esym && !expr->ref
              && expr->symtree->n.sym->attr.pointer
              && !expr->symtree->n.sym->attr.dimension)))
     {
index 16d6328..1d3e820 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-15  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/51082
+       * gfortran.dg/proc_ptr_comp_34.f90: New test case.
+
 2012-04-14  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52916
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_34.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_34.f90
new file mode 100644 (file)
index 0000000..031f744
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do run }
+!
+! PR 51082: [F03] Wrong result for a pointer to a proc-pointer component
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+program ala
+  implicit none
+
+  type process_list
+    procedure(ala1), pointer, nopass :: process
+  end type
+
+  type(process_list), target  :: p_list
+  type(process_list), pointer :: p
+
+  p_list%process => ala1
+  p => p_list
+
+   write(*,*) p_list%process(1.0)
+   write(*,*) p%process(1.0)       !!!! failed
+
+contains
+
+  real function ala1(x)
+    real, intent(in) :: x
+    ala1 = x
+  end function
+
+end program