public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR52864 - Fix pointer-intent regresssion
@ 2012-04-12  8:58 Tobias Burnus
  2012-04-15 15:07 ` Janus Weil
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-04-12  8:58 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

That's a GCC 4.6-4.8 regression. Pointer intents apply to the 
association status and not to the value. Thus,  assigning to an 
intent(in) pointer is fine. The problem was that the LHS is no pointer 
due to the array access ("dt%ptr(1) =") thus, the check got triggered.

Build and regtested on x86-64-linux.
OK for the trunk and the 4.6/4.7 branch?

Tobias

[-- Attachment #2: ptr-intent2.diff --]
[-- Type: text/x-patch, Size: 1516 bytes --]

20012-04-12  Tobias Burnus  <burnus@net-b.de>

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

20012-04-12  Tobias Burnus  <burnus@net-b.de>

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

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index e6a9c88..7ce693b 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4656,7 +4680,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)
     {
--- /dev/null	2012-04-12 06:55:49.927755790 +0200
+++ gcc/gcc/testsuite/gfortran.dg/pointer_intent_6.f90	2012-04-12 09:35:25.000000000 +0200
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, Fortran] PR52864 - Fix pointer-intent regresssion
  2012-04-12  8:58 [Patch, Fortran] PR52864 - Fix pointer-intent regresssion Tobias Burnus
@ 2012-04-15 15:07 ` Janus Weil
  0 siblings, 0 replies; 2+ messages in thread
From: Janus Weil @ 2012-04-15 15:07 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

Hi Tobias,

> That's a GCC 4.6-4.8 regression. Pointer intents apply to the association
> status and not to the value. Thus,  assigning to an intent(in) pointer is
> fine. The problem was that the LHS is no pointer due to the array access
> ("dt%ptr(1) =") thus, the check got triggered.
>
> Build and regtested on x86-64-linux.
> OK for the trunk and the 4.6/4.7 branch?

I'd say this patch is ok for trunk immediately, and for the branches
after a short waiting-period. Maybe you could extend the comment above
the code you're modifying?

Thanks,
Janus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-15 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12  8:58 [Patch, Fortran] PR52864 - Fix pointer-intent regresssion Tobias Burnus
2012-04-15 15:07 ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).