[Patch, fortran] PR27996 and PR29978 - warnings and errors on character lengths

Tobias Burnus burnus@net-b.de
Wed Nov 29 21:27:00 GMT 2006


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



More information about the Gcc-patches mailing list