This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR27996 and PR29978 - warnings and errors on character lengths
- From: Tobias Burnus <burnus at net-b dot de>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Wed, 29 Nov 2006 22:16:51 +0100
- Subject: Re: [Patch, fortran] PR27996 and PR29978 - warnings and errors on character lengths
- References: <456DE684.1030000@wanadoo.fr>
Hi Paul,
Paul Thomas wrote:
> + if (array && slen < len)
> + gfc_notify_std (GFC_STD_F2003, "F95 requires the CHARACTER elements "
> + "of the array constructor at %L to have the same "
> + "length (%d/%d)", &expr->where, slen, len);
>
And as Fortran 2003 requires the same you should use GFC_STD_GNU.
See:
"4.7 Construction of array values
[...]
"C494 (R466) If type-spec is omitted, each ac-value expression in the
array-constructor shall have the same type and kind type parameters.
[...]
"NOTE 4.72
"An example of an array constructor that specifies a length type parameter:
(/ CHARACTER(LEN=7) :: ’Takata’, ’Tanaka’, ’Hayashi’ /)
In this constructor, without the type specification, it would have been
necessary to specify all of the constants with the same character length."
g95, NAG f95 and sunf95 always reject these; ifort accepts them and only
outputs a warning with -stand f03 or f95.
Maybe one should output a (default?) warning for -std=gnu?
> + character(10) :: b(3)= (/ 'Takata ', 'Tanaka', 'Hayashi' /)
> + a = (/ 'Takata', 'Tanaka ', 'Hayashi' /) ! { dg-error "F95 requires" }
>
What is the difference between a and b? Or asking differently: Why is
the error detected for "a" and not for "b"?
Tobias