* [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes
@ 2010-03-05 9:37 Tobias Burnus
2010-03-14 5:56 ` *PING* " Tobias Burnus
2010-03-14 13:49 ` Daniel Kraft
0 siblings, 2 replies; 3+ messages in thread
From: Tobias Burnus @ 2010-03-05 9:37 UTC (permalink / raw)
To: gcc patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
Dear all,
when writing the first patch, I did some misreading of the standard.
a) Even for assumed-shape arrays, the codimensions have to be assumed
size - except if the coarray is allocatable. The check moved from
array.c to resolve.c; I also moved down one test and added an "else if"
to prevent two error message for the same problem.
b) I misread ultimate component; thus one can have a coarray of derived
type, which contains as component (1) an derived type with a coarray
component (2). If the former component (1) is allocatable or a pointer.
c) In one check, I missed a "c->allocatable".
Build on x86-64-linux and currently regtesting.
OK for the 4.6 stage1?
Tobias
[-- Attachment #2: coarray_decl_fixes.diff --]
[-- Type: text/x-patch, Size: 8816 bytes --]
C528 A nonallocatable coarray shall have a coarray-spec that is an
explicit-coshape-spec.
C525 An entity whose type has a coarray ultimate component shall be
a nonpointer nonallocatable scalar, shall not be a coarray,
and shall not be a function result.
1.3.29.4 ultimate component:
a component that is of intrinsic type, a pointer, or allocatable;
or an ultimate component of a nonpointer nonallocatable component
of derived type
fortran/array.c | 46 +++++++-----------------------------
fortran/gfortran.h | 2 -
fortran/parse.c | 3 +-
fortran/resolve.c | 18 +++++++++-----
testsuite/gfortran.dg/coarray_4.f90 | 2 -
testsuite/gfortran.dg/coarray_6.f90 | 26 ++++++++++++++++++++
6 files changed, 52 insertions(+), 45 deletions(-)
2010-03-05 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* gfortran.h (gfc_array_spec): Add cotype.
* array.c (gfc_match_array_spec,gfc_set_array_spec): Use it
and defer error diagnostic.
* resolve.c (resolve_fl_derived): Add missing check.
(resolve_symbol): Add cotype/type check.
* parse.c (parse_derived): Fix setting of coarray_comp.
2010-03-05 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* gfortran.dg/coarray_4.f90: Fix test.
* gfortran.dg/coarray_6.f90: Add more tests.
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index 4b2ccf6..c291ad8 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -342,7 +342,6 @@ match
gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim)
{
array_type current_type;
- array_type coarray_type = AS_UNKNOWN;
gfc_array_spec *as;
int i;
@@ -467,23 +466,10 @@ coarray:
if (current_type == AS_UNKNOWN)
goto cleanup;
- if (as->rank && as->type != AS_DEFERRED && current_type == AS_DEFERRED)
- {
- gfc_error ("Array at %C has non-deferred shape and deferred "
- "coshape");
- goto cleanup;
- }
- if (as->rank && as->type == AS_DEFERRED && current_type != AS_DEFERRED)
- {
- gfc_error ("Array at %C has deferred shape and non-deferred "
- "coshape");
- goto cleanup;
- }
-
if (as->corank == 1)
- coarray_type = current_type;
+ as->cotype = current_type;
else
- switch (coarray_type)
+ switch (as->cotype)
{ /* See how current spec meshes with the existing. */
case AS_UNKNOWN:
goto cleanup;
@@ -491,7 +477,7 @@ coarray:
case AS_EXPLICIT:
if (current_type == AS_ASSUMED_SIZE)
{
- coarray_type = AS_ASSUMED_SIZE;
+ as->cotype = AS_ASSUMED_SIZE;
break;
}
@@ -518,7 +504,7 @@ coarray:
if (current_type == AS_ASSUMED_SHAPE)
{
- as->type = AS_ASSUMED_SHAPE;
+ as->cotype = AS_ASSUMED_SHAPE;
break;
}
@@ -553,10 +539,11 @@ coarray:
goto cleanup;
}
- if (as->rank == 0 && coarray_type == AS_ASSUMED_SIZE)
- as->type = AS_EXPLICIT;
- else if (as->rank == 0)
- as->type = coarray_type;
+ if (as->cotype == AS_ASSUMED_SIZE)
+ as->cotype = AS_EXPLICIT;
+
+ if (as->rank == 0)
+ as->type = as->cotype;
done:
if (as->rank == 0 && as->corank == 0)
@@ -613,26 +600,13 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc)
return SUCCESS;
}
- if (sym->as->type == AS_DEFERRED && as->type != AS_DEFERRED)
- {
- gfc_error ("'%s' at %L has deferred shape and non-deferred coshape",
- sym->name, error_loc);
- return FAILURE;
- }
-
- if (sym->as->type != AS_DEFERRED && as->type == AS_DEFERRED)
- {
- gfc_error ("'%s' at %L has non-deferred shape and deferred coshape",
- sym->name, error_loc);
- return FAILURE;
- }
-
if (as->corank)
{
/* The "sym" has no corank (checked via gfc_add_codimension). Thus
the codimension is simply added. */
gcc_assert (as->rank == 0 && sym->as->corank == 0);
+ sym->as->cotype = as->cotype;
sym->as->corank = as->corank;
for (i = 0; i < as->corank; i++)
{
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index ad13b40..fb29bde 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -867,7 +867,7 @@ typedef struct
{
int rank; /* A rank of zero means that a variable is a scalar. */
int corank;
- array_type type;
+ array_type type, cotype;
struct gfc_expr *lower[GFC_MAX_DIMENSIONS], *upper[GFC_MAX_DIMENSIONS];
/* These two fields are used with the Cray Pointer extension. */
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index b68afba..190148c 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -2115,7 +2115,8 @@ endType:
sym->attr.proc_pointer_comp = 1;
/* Looking for coarray components. */
- if (c->attr.codimension || c->attr.coarray_comp)
+ if (c->attr.codimension
+ || (c->attr.coarray_comp && !c->attr.pointer && !c->attr.allocatable))
sym->attr.coarray_comp = 1;
/* Look for private components. */
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 4217c47..5f8a3e7 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -10466,7 +10466,8 @@ resolve_fl_derived (gfc_symbol *sym)
/* F2008, C444. */
if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.coarray_comp
- && (c->attr.codimension || c->attr.pointer || c->attr.dimension))
+ && (c->attr.codimension || c->attr.pointer || c->attr.dimension
+ || c->attr.allocatable))
{
gfc_error ("Component '%s' at %L with coarray component "
"shall be a nonpointer, nonallocatable scalar",
@@ -11304,11 +11305,6 @@ resolve_symbol (gfc_symbol *sym)
}
}
- if (sym->attr.codimension && sym->attr.allocatable
- && sym->as->type != AS_DEFERRED)
- gfc_error ("Allocatable coarray variable '%s' at %L must have "
- "deferred shape", sym->name, &sym->declared_at);
-
/* F2008, C526. */
if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp)
|| sym->attr.codimension)
@@ -11340,6 +11336,16 @@ resolve_symbol (gfc_symbol *sym)
gfc_error ("Variable '%s' at %L is a coarray or has a coarray "
"component and is not ALLOCATABLE, SAVE nor a "
"dummy argument", sym->name, &sym->declared_at);
+ /* F2008, C528. */
+ else if (sym->attr.codimension && !sym->attr.allocatable
+ && sym->as->cotype == AS_DEFERRED)
+ gfc_error ("Coarray variable '%s' at %L shall not have codimensions with "
+ "deferred shape", sym->name, &sym->declared_at);
+ else if (sym->attr.codimension && sym->attr.allocatable
+ && (sym->as->type != AS_DEFERRED || sym->as->cotype != AS_DEFERRED))
+ gfc_error ("Allocatable coarray variable '%s' at %L must have "
+ "deferred shape", sym->name, &sym->declared_at);
+
/* F2008, C541. */
if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp)
diff --git a/gcc/testsuite/gfortran.dg/coarray_4.f90 b/gcc/testsuite/gfortran.dg/coarray_4.f90
index 71fbf98..cb693ea 100644
--- a/gcc/testsuite/gfortran.dg/coarray_4.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_4.f90
@@ -48,7 +48,7 @@ subroutine invalid(n)
integer, save :: hf4(5)[n,*] ! { dg-error "cannot have the SAVE attribute" }
integer, allocatable :: a2[*] ! { dg-error "must have deferred shape" }
- integer, allocatable :: a3(:)[*] ! { dg-error "deferred shape and non-deferred coshape" }
+ integer, allocatable :: a3(:)[*] ! { dg-error "must have deferred shape" }
integer, allocatable :: a4[*] ! { dg-error "must have deferred shape" }
end subroutine invalid
diff --git a/gcc/testsuite/gfortran.dg/coarray_6.f90 b/gcc/testsuite/gfortran.dg/coarray_6.f90
index f122fd4..b6d8b49 100644
--- a/gcc/testsuite/gfortran.dg/coarray_6.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_6.f90
@@ -51,6 +51,32 @@ function func() result(func2) ! { dg-error "shall not be a coarray or have a coa
type(t) :: func2
end function func
+subroutine invalid()
+ type t
+ integer, allocatable :: a[:]
+ end type t
+ type t2
+ type(t), allocatable :: b ! { dg-error "nonpointer, nonallocatable scalar" }
+ end type t2
+ type t3
+ type(t), pointer :: c ! { dg-error "nonpointer, nonallocatable scalar" }
+ end type t3
+ type t4
+ type(t) :: d(4) ! { dg-error "nonpointer, nonallocatable scalar" }
+ end type t4
+end subroutine invalid
+
+subroutine valid(a)
+ integer :: a(:)[4,-1:6,4:*]
+ type t
+ integer, allocatable :: a[:]
+ end type t
+ type t2
+ type(t) :: b
+ end type t2
+ type(t2), save :: xt2[*]
+end subroutine valid
+
program main
integer :: A[*] ! Valid, implicit SAVE attribute
end program main
^ permalink raw reply [flat|nested] 3+ messages in thread
* *PING* Re: [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes
2010-03-05 9:37 [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes Tobias Burnus
@ 2010-03-14 5:56 ` Tobias Burnus
2010-03-14 13:49 ` Daniel Kraft
1 sibling, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2010-03-14 5:56 UTC (permalink / raw)
To: gcc patches, gfortran
*PING*
http://gcc.gnu.org/ml/fortran/2010-03/msg00032.html
On 5 March 2010 09:00, Tobias Burnus wrote:
> when writing the first patch, I did some misreading of the standard.
>
> a) Even for assumed-shape arrays, the codimensions have to be assumed
> size - except if the coarray is allocatable. The check moved from
> array.c to resolve.c; I also moved down one test and added an "else if"
> to prevent two error message for the same problem.
>
> b) I misread ultimate component; thus one can have a coarray of derived
> type, which contains as component (1) an derived type with a coarray
> component (2). If the former component (1) is allocatable or a pointer.
>
> c) In one check, I missed a "c->allocatable".
>
> Build on x86-64-linux and currently regtesting.
> OK for the 4.6 stage1?
>
> Tobias
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes
2010-03-05 9:37 [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes Tobias Burnus
2010-03-14 5:56 ` *PING* " Tobias Burnus
@ 2010-03-14 13:49 ` Daniel Kraft
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Kraft @ 2010-03-14 13:49 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc patches, gfortran
Tobias Burnus wrote:
> Dear all,
>
> when writing the first patch, I did some misreading of the standard.
>
> a) Even for assumed-shape arrays, the codimensions have to be assumed
> size - except if the coarray is allocatable. The check moved from
> array.c to resolve.c; I also moved down one test and added an "else if"
> to prevent two error message for the same problem.
>
> b) I misread ultimate component; thus one can have a coarray of derived
> type, which contains as component (1) an derived type with a coarray
> component (2). If the former component (1) is allocatable or a pointer.
>
> c) In one check, I missed a "c->allocatable".
>
> Build on x86-64-linux and currently regtesting.
> OK for the 4.6 stage1?
Ok. thanks for this patch again and your co-array work!
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-14 13:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-05 9:37 [Patch, Fortran, 4.6] Coarray 5/n: Some coarray declaration fixes Tobias Burnus
2010-03-14 5:56 ` *PING* " Tobias Burnus
2010-03-14 13:49 ` Daniel Kraft
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).