diff mbox

[Fortran] Add missing coarray check

Message ID 53C437DA.2050800@net-b.de
State New
Headers show

Commit Message

Tobias Burnus July 14, 2014, 8:04 p.m. UTC
While checking whether gfortran already handles the new constraint at 
http://j3-fortran.org/doc/year/14/14-140r2.txt (it does), I found the 
following issues:

a) Coarray variables with pointer attribute weren't rejected.
b) There was a copy'n'paste error in symbol.c, having cray_pointer at 
places where one should have cray_pointee, such that the cray-pointer 
test had been done twice.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

* * *

Admittedly, I cannot find the constraint for (a), but I am certain that 
it is not intended to permit the POINTER attribute. Even using C526 plus 
C528 still seem to permit "integer, save, pointer :: caf[*]". I have now 
asked at the J3 mailing list for a pointer to the right constraint. At 
least Cray's compiler (correctly?!?) rejects coarrays with pointer 
attribute.

Tobias

Comments

Tobias Burnus July 15, 2014, 5:39 a.m. UTC | #1
I have now committed it as obvious.

The constraint, I couldn't find, was/is C546 (thanks to Reinhard Bader). 
With coarrays, I tend to have the problem whether the best search term 
is coarray or codimension (or sometimes also: coindexed, corank).

Committed as Rev. 212540

Tobias

Tobias Burnus wrote:
> While checking whether gfortran already handles the new constraint at 
> http://j3-fortran.org/doc/year/14/14-140r2.txt (it does), I found the 
> following issues:
>
> a) Coarray variables with pointer attribute weren't rejected.
> b) There was a copy'n'paste error in symbol.c, having cray_pointer at 
> places where one should have cray_pointee, such that the cray-pointer 
> test had been done twice.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> * * *
>
> Admittedly, I cannot find the constraint for (a), but I am certain 
> that it is not intended to permit the POINTER attribute. Even using 
> C526 plus C528 still seem to permit "integer, save, pointer :: 
> caf[*]". I have now asked at the J3 mailing list for a pointer to the 
> right constraint. At least Cray's compiler (correctly?!?) rejects 
> coarrays with pointer attribute.
>
> Tobias
diff mbox

Patch

2014-06-14  Tobias Burnus  <burnus@net-b.de>

gcc/fortran/
	* symbol.c (check_conflict): Add codimension conflict with
	pointer; fix cray-pointee check.

gcc/testsuite/
	* gfortran.dg/coarray_34.f90: New.
	* gfortran.dg/coarray_6.f90: Update test case.

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index aee7510..2e04598 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -458,6 +458,7 @@  check_conflict (symbol_attribute *attr, const char *name, locus *where)
   conf (pointer, target);
   conf (pointer, intrinsic);
   conf (pointer, elemental);
+  conf (pointer, codimension);
   conf (allocatable, elemental);
 
   conf (target, external);
@@ -534,8 +535,8 @@  check_conflict (symbol_attribute *attr, const char *name, locus *where)
   conf (cray_pointer, entry);
 
   conf (cray_pointee, allocatable);
-  conf (cray_pointer, contiguous);
-  conf (cray_pointer, codimension);
+  conf (cray_pointee, contiguous);
+  conf (cray_pointee, codimension);
   conf (cray_pointee, intent);
   conf (cray_pointee, optional);
   conf (cray_pointee, dummy);
diff --git a/gcc/testsuite/gfortran.dg/coarray_34.f90 b/gcc/testsuite/gfortran.dg/coarray_34.f90
new file mode 100644
index 0000000..f2bc910
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_34.f90
@@ -0,0 +1,26 @@ 
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+use iso_fortran_env
+implicit none
+
+type t
+  integer, pointer :: caf2[:] ! { dg-error "must be allocatable with deferred shape" }
+end type t
+
+integer, pointer :: caf[*] ! { dg-error "POINTER attribute conflicts with CODIMENSION attribute" }
+
+type t2
+  type(lock_type), pointer :: lock_it ! { dg-error "Component lock_it at .1. of type LOCK_TYPE must have a codimension or be a subcomponent of a coarray, which is not possible as the component has the pointer attribute" }
+end type t2
+type(t2) :: caf3[*]
+
+type t3
+  type(lock_type) :: x
+end type t3
+
+type t4
+  type(t3), pointer :: y ! { dg-error "Pointer component y at .1. has a noncoarray subcomponent of type LOCK_TYPE, which must have a codimension or be a subcomponent of a coarray" }
+end type t4
+
+end
diff --git a/gcc/testsuite/gfortran.dg/coarray_6.f90 b/gcc/testsuite/gfortran.dg/coarray_6.f90
index f44ac01..d30567a 100644
--- a/gcc/testsuite/gfortran.dg/coarray_6.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_6.f90
@@ -32,7 +32,7 @@  end module m
 
 subroutine bar()
   integer, parameter :: a[*] = 4 ! { dg-error "PARAMETER attribute conflicts with CODIMENSION" }
-  integer, pointer :: b[:] ! { dg-error "is not ALLOCATABLE, SAVE nor a dummy" }
+  integer :: b[*] ! { dg-error "is not ALLOCATABLE, SAVE nor a dummy" }
 end subroutine bar
 
 subroutine vol()