Patchwork [Fortran] PR 45586: Mark type pointer components as nonrestricted

login
register
mail settings
Submitter Tobias Burnus
Date July 27, 2011, 8:39 p.m.
Message ID <4E307778.10106@net-b.de>
Download mbox | patch
Permalink /patch/107146/
State New
Headers show

Comments

Tobias Burnus - July 27, 2011, 8:39 p.m.
See discussion at http://gcc.gnu.org/ml/fortran/2011-07/msg00281.html 
and see PR 45586.

This patch fixes the test case of the PR by properly using the 
nonrestricted type for pointer components. Before, the test case failed 
(ICE) in some tree checking. While the ICE only affects the trunk (more 
precisely: --enable-checking={yes,tree}), the issue itself also affects 
the branches.

I am not completely sure that the patch covers all restrict/nonrestrict 
issues, but it fixes the PR and I couldn't create a variant which still 
gave an ICE.

Build and regtested on x86-64-linux.
OK for the trunk? What about backporting to 4.6 and to 4.5?

Tobias
Mikael Morin - July 27, 2011, 10:27 p.m.
On Wednesday 27 July 2011 22:39:20 Tobias Burnus wrote:
> See discussion at http://gcc.gnu.org/ml/fortran/2011-07/msg00281.html
> and see PR 45586.
> 
> This patch fixes the test case of the PR by properly using the
> nonrestricted type for pointer components. Before, the test case failed
> (ICE) in some tree checking. While the ICE only affects the trunk (more
> precisely: --enable-checking={yes,tree}), the issue itself also affects
> the branches.
> 
> I am not completely sure that the patch covers all restrict/nonrestrict
> issues, but it fixes the PR and I couldn't create a variant which still
> gave an ICE.
I think the patch is good. Anyway, it shouldn't make things worse, which makes 
it good enough at least.

> 
> Build and regtested on x86-64-linux.
> OK for the trunk? What about backporting to 4.6 and to 4.5?
OK for trunk and 4.6. 
4.5 doesn't have the gfc_nonrestricted_type function, so it's not worth the 
bother IMO (unless you feel like backporting Michael's patch ;-) ).

Thanks
Mikael
Tobias Burnus - July 27, 2011, 10:41 p.m.
Mikael Morin wrote:
>> Build and regtested on x86-64-linux.
>> OK for the trunk? What about backporting to 4.6 and to 4.5?
> OK for trunk and 4.6.
> 4.5 doesn't have the gfc_nonrestricted_type function, so it's not worth the
> bother IMO (unless you feel like backporting Michael's patch ;-) ).

Thanks for the quick review! I don't plan to backport 
gfc_nonrestricted_type - thus, I will follow your suggestion to only 
backport it to 4.6 ;-)

I have now committed the patch to the trunk (Rev. 176852) - and will 
commit later to the branch.

Thanks,

Tobias

Patch

2011-07-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45586
	* trans-types.c (gfc_get_derived_type): Ensure that pointer
	component types are marked as nonrestricted.

2011-07-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45586
	* gfortran.dg/lto/pr45586-2_0.f90: New.

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index b66941f..bec2a11 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2421,6 +2421,9 @@  gfc_get_derived_type (gfc_symbol * derived)
 	       && !c->attr.proc_pointer)
 	field_type = build_pointer_type (field_type);
 
+      if (c->attr.pointer)
+	field_type = gfc_nonrestricted_type (field_type);
+
       /* vtype fields can point to different types to the base type.  */
       if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.vtype)
 	  field_type = build_pointer_type_for_mode (TREE_TYPE (field_type),
--- /dev/null	2011-07-27 08:24:41.216620249 +0200
+++ gcc/gcc/testsuite/gfortran.dg/lto/pr45586-2_0.f90	2011-07-27 21:44:48.000000000 +0200
@@ -0,0 +1,34 @@ 
+! { dg-lto-do link }
+!
+! PR fortran/45586 (comment 53)
+!
+
+MODULE M1
+  INTEGER, PARAMETER :: dp=8
+  TYPE realspace_grid_type
+     REAL(KIND=dp), DIMENSION ( :, :, : ), ALLOCATABLE :: r
+  END TYPE realspace_grid_type
+  TYPE realspace_grid_p_type
+     TYPE(realspace_grid_type), POINTER :: rs_grid
+  END TYPE realspace_grid_p_type
+  TYPE realspaces_grid_p_type
+     TYPE(realspace_grid_p_type), DIMENSION(:), POINTER :: rs
+  END TYPE realspaces_grid_p_type
+END MODULE
+
+MODULE M2
+ USE M1
+CONTAINS
+ SUBROUTINE S1()
+  INTEGER :: i,j
+  TYPE(realspaces_grid_p_type), DIMENSION(:), POINTER :: rs_gauge
+  REAL(dp), DIMENSION(:, :, :), POINTER    :: y
+  y=>rs_gauge(i)%rs(j)%rs_grid%r
+ END SUBROUTINE
+END MODULE
+
+USE M2
+  CALL S1()
+END
+
+! { dg-final { cleanup-modules "m1 m2" } }