This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[fortran, patch] PR32467 - structure containing allocatable array is wrongly accepted


As allocatable components in derived types are not part of F95, OpenMP v2.5 
does not allow such in clauses where allocatable arrays are not allowed. 
These clauses are: COPYIN, COPYPRIVATE, FIRSTPRIVATE, LASTPRIVATE, REDUCTION.
	

:ADDPATCH fortran:

2007-06-24  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32467
	* openmp.c (resolve_omp_clauses): Emit error on allocatable components 
	in COPYIN, COPYPRIVATE, FIRSTPRIVATE, LASTPRIVATE and REDUCTION clauses.

2007-06-24  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32467
	* gfortran.dg/gomp/allocatable_components_1.f90: New test.


Bootstrapped and regression tested on i686-pc-linux-gnu. Ok for trunk?

Regards
	Daniel
Index: fortran/openmp.c
===================================================================
--- fortran/openmp.c	(revision 125970)
+++ fortran/openmp.c	(working copy)
@@ -779,6 +779,9 @@
 		if (n->sym->attr.allocatable)
 		  gfc_error ("COPYIN clause object '%s' is ALLOCATABLE at %L",
 			     n->sym->name, &code->loc);
+		if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+		  gfc_error ("COPYIN clause object '%s' at %L has ALLOCATABLE components",
+			     n->sym->name, &code->loc);
 	      }
 	    break;
 	  case OMP_LIST_COPYPRIVATE:
@@ -790,6 +793,9 @@
 		if (n->sym->attr.allocatable)
 		  gfc_error ("COPYPRIVATE clause object '%s' is ALLOCATABLE "
 			     "at %L", n->sym->name, &code->loc);
+		if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+		  gfc_error ("COPYPRIVATE clause object '%s' at %L has ALLOCATABLE components",
+			     n->sym->name, &code->loc);
 	      }
 	    break;
 	  case OMP_LIST_SHARED:
@@ -820,6 +826,9 @@
 		    if (n->sym->attr.allocatable)
 		      gfc_error ("%s clause object '%s' is ALLOCATABLE at %L",
 				 name, n->sym->name, &code->loc);
+		    if (n->sym->ts.type == BT_DERIVED && n->sym->ts.derived->attr.alloc_comp)
+		      gfc_error ("%s clause object '%s' has ALLOCATABLE components at %L",
+				 name, n->sym->name, &code->loc);
 		    if (n->sym->attr.cray_pointer)
 		      gfc_error ("Cray pointer '%s' in %s clause at %L",
 				 n->sym->name, name, &code->loc);
Index: testsuite/gfortran.dg/gomp/allocatable_components_1.f90
===================================================================
--- testsuite/gfortran.dg/gomp/allocatable_components_1.f90	(revision 0)
+++ testsuite/gfortran.dg/gomp/allocatable_components_1.f90	(revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/32467
+! Derived types with allocatable components in COPYIN
+!
+! Contributed by Bill Long <longb AT cray DOT com>
+!
+
+      type structure_1
+          integer, allocatable :: a(:)
+      end type structure_1
+      type(structure_1), save :: struc1
+
+!$omp threadprivate(struc1)
+!$omp parallel copyin(struc1)                ! { dg-error "has ALLOCATABLE components" }
+      ! do something
+!$omp end parallel
+
+      END

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]