[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-04-17 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Dominique d'Humieres  ---
> If nobody objects, I'll close the PR as FIXED again.

No objection after almost a month. Closing.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-03-20 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

--- Comment #8 from Dominique d'Humieres  ---
module A

Type T
character(LEN=:), allocatable :: S
end type
character(len=6), parameter :: str = 'string'
Type(T) :: TestObj = T(str)

end module

is rejected with

 Type(T) :: TestObj = T(str)
   1
Error: Invalid initialization expression for ALLOCATABLE component 's' in
structure constructor at (1)

So it seems that

>  (a) an allocatable component is a reference to the intrinsic function 
> NULL,

has to be taken in the most restrictive way.

If nobody objects, I'll close the PR as FIXED again.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-03-20 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

--- Comment #7 from vehre at gcc dot gnu.org ---
First sentence of F2008, 7.1.12 is:

   A constant expression is an expression with limitations that make it 
   suitable for use as a kind type parameter, *initializer*, or named 
   constant. It is an expression in which each operation is intrinsic,
   and each primary is ...

With Type(T) :: TestObj = T(...) the T after the assign becomes an initializer,
which 7.1.12 states only constant expressions are suitable for. In this
constant expression each structure constructor has to adhere to the conditions
of (3):

   a structure constructor where each component-spec corresponding to
 (a) an allocatable component is a reference to the intrinsic function
NULL,
 (b) ...

Now that S is an allocatable component of T. I think this the only valid
expression for that is NULL() as initializer. This is what gfortran does
currently and this is how I interpret the standard.

Btw, cosmomc compiles fine, so it can't be using this specific construct.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-03-20 Thread antony at cosmologist dot info
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

--- Comment #6 from Antony Lewis  ---
Not sure about that - 7.1.12 of 2008 is about constants, but in the example the
type instance is not a constant? The example is fine in ifort (and used in
cosmomc?).

Antony

> -Original Message-
> From: vehre at gcc dot gnu.org [mailto:gcc-bugzi...@gcc.gnu.org]
> Sent: 20 March 2015 11:59 AM
> To: ant...@cosmologist.info
> Subject: [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE
> component in structure constructor at (1)
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
> 
> --- Comment #5 from vehre at gcc dot gnu.org ---
> Completely right, the initial test is still not compilable. But this is 
> because
> assigning to an allocatable component in an initializer is not allowed by the
> standards:
> F2003, 7.1.7 (3) and also in
> F2008, 7.1.12 (3).
> 
> So the correct code would be:
> 
> module A
> 
> Type T
> character(LEN=:), allocatable :: S
> end type
> Type(T) :: TestObj = T(NULL())
> 
> TestObj%S = 'string'
> 
> contains
> 
> end module
> 
> which compiles and runs w/o error.
> Standard compliant implementation is tested for in
> 
> gfortran.dg/alloc_comp_init_expr.f03
> 
> only far allocatable arrays, but that's near enough for char arrays for me.
> 
> --
> You are receiving this mail because:
> You reported the bug.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-03-20 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

--- Comment #5 from vehre at gcc dot gnu.org ---
Completely right, the initial test is still not compilable. But this is because
assigning to an allocatable component in an initializer is not allowed by the
standards:
F2003, 7.1.7 (3) and also in
F2008, 7.1.12 (3).

So the correct code would be:

module A

Type T
character(LEN=:), allocatable :: S
end type
Type(T) :: TestObj = T(NULL())

TestObj%S = 'string'

contains

end module

which compiles and runs w/o error.
Standard compliant implementation is tested for in 

gfortran.dg/alloc_comp_init_expr.f03

only far allocatable arrays, but that's near enough for char arrays for me.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-03-20 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #4 from Dominique d'Humieres  ---
Sorry for the late reaction, but the original test is still giving the same
error with a clean tree at r221069.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-01-23 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

vehre at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||vehre at gcc dot gnu.org
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |vehre at gcc dot gnu.org

--- Comment #3 from vehre at gcc dot gnu.org ---
Resolved with commit r219801.
Thanks Paul for commiting.


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2015-01-17 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

--- Comment #2 from Paul Thomas  ---
Author: pault
Date: Sat Jan 17 18:08:38 2015
New Revision: 219801

URL: https://gcc.gnu.org/viewcvs?rev=219801&root=gcc&view=rev
Log:
2015-01-17  Andre Vehreschild  

PR fortran/60357
* primary.c (build_actual_constructor): Prevent warning.
* trans-expr.c (alloc_scalar_allocatable_for_subcomponent_
assignment): New function encapsulates treatment of allocatable
components.
(gfc_trans_subcomponent_assign): Needed to distinguish between
regular assignment and initilization.
(gfc_trans_structure_assign): Same.
(gfc_conv_structure): Same.

PR fortran/61275
* gfortran.h: deferred_parameter is not needed, because
it artificial does the trick completely.
* primary.c (build_actual_constructor): Same.
(gfc_convert_to_structure_constructor): Same.
* resolve.c (resolve_fl_derived0): Same.
* trans-expr.c (gfc_conv_component_ref): Prevent treating
allocatable deferred length char arrays here.
(gfc_trans_subcomponent_assign): Same as above.
* trans-types.c (gfc_sym_type): This is done in
gfc_get_derived_type already.

2015-01-17  Andre Vehreschild  

PR fortran/60357
* gfortran.dg/alloc_comp_assign_13.f08: New test.

PR fortran/61275
* gfortran.dg/alloc_comp_assign_14.f08: New test.

PR fortran/55932
* gfortran.dg/alloc_comp_initializer_4.f03: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/alloc_comp_assign_13.f08
trunk/gcc/testsuite/gfortran.dg/alloc_comp_assign_14.f08
trunk/gcc/testsuite/gfortran.dg/alloc_comp_initializer_4.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/primary.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-types.c
trunk/gcc/testsuite/ChangeLog


[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)

2014-05-23 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-05-23
 CC||pault at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres  ---
Confirmed on 4.9.0 and trunk (4.10).