This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
PR23152 - namelist can't contain an assumed size array - a standards question
- From: THOMAS Paul Richard 169137 <prthomas at drfccad dot cea dot fr>
- To: "'Richard dot Maine at nasa dot gov'" <Richard dot Maine at nasa dot gov>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, "'tkoenig at gcc dot gnu dot org'" <tkoenig at gcc dot gnu dot org>
- Date: Wed, 10 Aug 2005 09:43:42 +0200
- Subject: PR23152 - namelist can't contain an assumed size array - a standards question
Richard,
Thomas Koenig and I have been in correspondence about the above PR. I copy
below my last message to Thomas, which includes a patch that I am coming to
believe over-does it. The nub of the question is, what, in the F95
standard, constitutes "an array dummy argument with nonconstant bounds"? It
is manifestly an assumed size array but does it include an assumed shape
array too? ifc and Digital 5.0 give an error on assumed shape arrays,
whereas gfortran happily chomps them up. Thus, the issue comes down to
matching the errors and warnings to the intention of the F95 standard. The
F2003 standard is completely clear on the issue.
Best regards
Paul Thomas
==============================================================
Thomas,
The standard changed between f95 and f2003. I used the latter, when working
on namelist.
f95 says:
The following variables cannot be specified in a namelist group:
An array dummy argument with nonconstant bounds
A variable with assumed character length
An allocatable array
An automatic object
A pointer
A variable of a type that has a pointer as an ultimate component
A subobject of any of the above objects
, whereas f2003 says:
C573 (R552) The namelist-group-name shall not be a name made accessible by
use association.
R553 namelist-group-object is variable-name.
C574 (R553) A namelist-group-object shall not be an assumed-size array.
C575 (R552) A namelist-group-object shall not have the PRIVATE attribute if
the namelist-group-
name has the PUBLIC attribute.
Strictly speaking, namelist_14.f90 complies with both, since array(:) has
constant bounds and is assumed shape.
The patch (Some turkey has changed the firewall, so that cvs is failing to
make a temporary directory. I have had to attach an extract from module.c.)
that I have attached accidentally respects this because it is not identified
as being assumed size until some later time in the compilation. However,
array(*) now bombs in all conditions, and array(a:) gives warnings, except
with -std=f2003, and bombs for -std=gnu or earlier. Should gnu be allowed,
I wonder?
I have included two test programs that will be turned into test cases
tonight.
Best regards
Paul
PS After writing this, I got to wondering just what non-constant bounds
includes; definitely assumed-size but what about assumed shape? There is a
group of assumed shape declarations that escape my test. They can be dealt
with in the io statement itself but life would be easier if there is no
need!
Just after (match.c:2471)
if (sym->attr.in_namelist == 0
&& gfc_add_in_namelist (&sym->attr, sym->name, NULL) ==
FAILURE)
goto error;
Insert
if (sym->as && sym->as->type == AS_ASSUMED_SIZE
&& gfc_notify_std (0, "assumed size array '%s' in namelist
'%s'"
" at %C", sym->name, group_name->name)
== FAILURE)
goto error;
/* Use gfc_error_check here, rather than goto error, so that this
is the only error for this line. */
if (sym->as && sym->as->type == AS_ASSUMED_SHAPE
&& gfc_notify_std (GFC_STD_F2003, "Assumed shape array '%s'
in "
"namelist '%s' at %C is an F2003
feature",
sym->name, group_name->name) == FAILURE)
gfc_error_check ();
program assumed_size_nml
real, dimension (10) :: z
z = 42.0
call foo (z)
contains
subroutine foo (y)
real, DIMENSION (1:) :: y
namelist /mynml/ y
write (*, mynml)
end subroutine foo
end program assumed_size_nml
program assumed_shape_nml
real, dimension (10) :: z
z = 42.0
call foo (z)
contains
subroutine foo (y)
real, DIMENSION (1:) :: y
namelist /mynml/ y
write (*, mynml)
end subroutine foo
end program assumed_shape_nml