[fortran, patch] PR34402, accepts invalid init expr
Tobias Burnus
burnus@net-b.de
Thu Dec 10 19:26:00 GMT 2009
Hi Daniel,
Daniel Franke wrote:
> there's a condition on initialization expressions, that allocatable
components
> shall not be initialized with data but NULL(). Attached patch adds a
check for
> this. The testcase is the reporter's.
Thanks for the patch. Can you add an initialization expression which
uses NULL()? I only found it in
alloc_comp_{constructor,initializer}_1.f90, but those are not init expr.
> The wording of the error message is a bit awkward and longish, any other
> suggestions?
The patch uses:
"The data initialization in the derived type constructor at %L for the
ALLOCATABLE component '%s' is invalid in initialization expressions"
In standard lingo one does not use "derived-type constructor" but
"structure constructor", which is 3 letters shorter but I am not sure
whether it is clearer. I came up with the following version (and using
optionally the term "allocatable"):
"Invalid initialization expression for [allocatable] component '%s' in
structure constructor at %L"
> 2009-12-10 Daniel Franke <franke.daniel@gmail.com>
>
> PR fortran/34402
> * expr.c (check_alloc_comp_init): New.
> (check_init_expr): Verify that allocatable components are not
> data-initalized.
>
> 2009-12-10 Daniel Franke <franke.daniel@gmail.com>
>
> PR fortran/34402
> * gfortran.dg/alloc_comp_init_expr.f03: New.
>
>
> Regression tested on i686-pc-linux-gnu. Ok for trunk?
OK with the additional NULL() init expr and considering a shorter
version of the error message.
Tobias
More information about the Fortran
mailing list