[multiple changes]
authorTobias Burnus <burnus@net-b.de>
Mon, 16 Apr 2012 21:47:35 +0000 (23:47 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Mon, 16 Apr 2012 21:47:35 +0000 (23:47 +0200)
2012-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * expr.c (gfc_check_vardef_context): Fix assignment check for
        pointer components.

2012-04-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * gfortran.dg/pointer_intent_6.f90: New.

From-SVN: r186507

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

index 18e17cdabcba7b1c5b3fd9bb7660d17cae56ed89..9793c8b57b0b356fbcff13797316f68a69d17da4 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-16  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/52864
+       * expr.c (gfc_check_vardef_context): Fix assignment check for
+       pointer components.
+
 2012-04-16  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/52968
index e6a9c885f0236cc6a6ce28e791133ac26bc7421a..d9614413e67eaacffa9511bb547381954132c2e9 100644 (file)
@@ -4645,9 +4645,11 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
       return FAILURE;
     }
 
-  /* INTENT(IN) dummy argument.  Check this, unless the object itself is
-     the component of sub-component of a pointer.  Obviously,
-     procedure pointers are of no interest here.  */
+  /* INTENT(IN) dummy argument.  Check this, unless the object itself is the
+     component of sub-component of a pointer; we need to distinguish
+     assignment to a pointer component from pointer-assignment to a pointer
+     component.  Note that (normal) assignment to procedure pointers is not
+     possible.  */
   check_intentin = true;
   ptr_component = (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
                  ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer;
@@ -4656,7 +4658,11 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
       if (ptr_component && ref->type == REF_COMPONENT)
        check_intentin = false;
       if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer)
-       ptr_component = true;
+       {
+         ptr_component = true;
+         if (!pointer)
+           check_intentin = false;
+       }
     }
   if (check_intentin && sym->attr.intent == INTENT_IN)
     {
index b07f556edaa071c01b5ea199a52d5e7ecc529975..79a724ebb9c72aa5644db816232e0d468aa64fa8 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-16  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/52864
+       * gfortran.dg/pointer_intent_6.f90: New.
+
 2012-04-16  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52916
diff --git a/gcc/testsuite/gfortran.dg/pointer_intent_6.f90 b/gcc/testsuite/gfortran.dg/pointer_intent_6.f90
new file mode 100644 (file)
index 0000000..56c7de5
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/52864
+!
+! Assigning to an intent(in) pointer (which is valid).
+!
+      program test
+         type PoisFFT_Solver3D
+           complex, dimension(:,:,:), &
+                           pointer :: work => null()
+         end type PoisFFT_Solver3D
+      contains
+        subroutine PoisFFT_Solver3D_FullPeriodic(D, p)
+          type(PoisFFT_Solver3D), intent(in) :: D
+          real, intent(in), pointer :: p(:)
+          D%work(i,j,k) = 0.0
+          p = 0.0
+        end subroutine
+      end