[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2016-11-16 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

janus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||janus at gcc dot gnu.org
   Target Milestone|--- |7.0

[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2016-10-31 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

vehre at gcc dot gnu.org changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from vehre at gcc dot gnu.org ---
No complaints so far, closing.

[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2016-10-24 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

vehre at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |WAITING
   Assignee|unassigned at gcc dot gnu.org  |vehre at gcc dot gnu.org

--- Comment #4 from vehre at gcc dot gnu.org ---
Waiting one week for regression reports.

[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2016-10-22 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

--- Comment #3 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Sat Oct 22 12:33:38 2016
New Revision: 241439

URL: https://gcc.gnu.org/viewcvs?rev=241439=gcc=rev
Log:
gcc/fortran/ChangeLog:

2016-10-22  Andre Vehreschild  

PR fortran/43366
PR fortran/51864
PR fortran/57117
PR fortran/61337
PR fortran/61376
* primary.c (gfc_expr_attr): For transformational functions on classes
get the attrs from the class argument.
* resolve.c (resolve_ordinary_assign): Remove error message due to
feature implementation.  Rewrite POINTER_ASSIGNS to ordinary ones when
the right-hand side is scalar class object (with some restrictions).
* trans-array.c (trans_array_constructor): Create the temporary from
class' inner type, i.e., the derived type.
(build_class_array_ref): Add support for class array's storage of the
class object or the array descriptor in the decl saved descriptor.
(gfc_conv_expr_descriptor): When creating temporaries for class objects
add the class object's handle into the decl saved descriptor.
(structure_alloc_comps): Use the common way to get the _data component.
(gfc_is_reallocatable_lhs): Add notion of allocatable class objects.
* trans-expr.c (gfc_find_and_cut_at_last_class_ref): Remove the only
ref
only when the expression's type is BT_CLASS.
(gfc_trans_class_init_assign): Correctly handle class arrays.
(gfc_trans_class_assign): Joined into gfc_trans_assignment_1.
(gfc_conv_procedure_call): Support for class types as arguments.
(trans_get_upoly_len): For unlimited polymorphics retrieve the _len
component's tree.
(trans_class_vptr_len_assignment): Catch all ways to assign the _vptr
and _len components of a class object correctly.
(pointer_assignment_is_proc_pointer): Identify assignments of
procedure pointers.
(gfc_trans_pointer_assignment): Enhance support for class object
pointer
assignments.
(gfc_trans_scalar_assign): Removed assert.
(trans_class_assignment): Assign to a class object.
(gfc_trans_assignment_1): Treat class objects correctly.
(gfc_trans_assignment): Propagate flags to trans_assignment_1.
* trans-stmt.c (gfc_trans_allocate): Use gfc_trans_assignment now
instead of copy_class_to_class.
* trans-stmt.h: Function prototype removed.
* trans.c (trans_code): Less special casing for class objects.
* trans.h: Added flags to gfc_trans_assignment () prototype.

gcc/testsuite/ChangeLog:

2016-10-22  Andre Vehreschild  

Forgot to add on original commit.
* gfortran.dg/coarray_alloc_comp_2.f08: New test.

2016-10-22  Andre Vehreschild  

PR fortran/43366
PR fortran/57117
PR fortran/61337
* gfortran.dg/alloc_comp_class_5.f03: New test.
* gfortran.dg/class_allocate_21.f90: New test.
* gfortran.dg/class_allocate_22.f90: New test.
* gfortran.dg/realloc_on_assign_27.f08: New test.



Added:
trunk/gcc/testsuite/gfortran.dg/alloc_comp_class_5.f03
trunk/gcc/testsuite/gfortran.dg/class_allocate_21.f90
trunk/gcc/testsuite/gfortran.dg/class_allocate_22.f90
trunk/gcc/testsuite/gfortran.dg/coarray_alloc_comp_2.f08
trunk/gcc/testsuite/gfortran.dg/realloc_on_assign_27.f08
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/primary.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/fortran/trans-stmt.h
trunk/gcc/fortran/trans.c
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog

[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2014-07-20 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-07-20
 Ever confirmed|0   |1

--- Comment #2 from Dominique d'Humieres dominiq at lps dot ens.fr ---
Compiling the code in comment 0 still gives an ICE with gfortran 4.10.0 r212833
(the same ICE as for pr53653):

pr51864.f90: In function 'MAIN__':
pr51864.f90:12:0: internal compiler error: in gfc_conv_array_constructor_expr,
at fortran/trans-expr.c:5668
 allocate(c(8), source=[ a, b ])
 ^

I also get the same ICE with the following code

  call pr53876
end

subroutine pr53876
  IMPLICIT NONE
  TYPE :: individual
integer :: icomp ! Add an extra component to test offset
REAL, DIMENSION(:), ALLOCATABLE :: genes
  END TYPE
  CLASS(individual), DIMENSION(:), ALLOCATABLE :: indv, indv1
  allocate (indv(2), source = [individual(1, [99,999]), 
   individual(2, [999,])])
  allocate (indv1(2), source = [indv])
END

If I understand correctly comment 1, this code should be valid. Replacing
'[indv]' with '[indv(1),indv(2)]' does not fix the ICE, but replacing it with
'imdv' does.


[Bug fortran/51864] [OOP] ALLOCATE with polymorphic array constructor as SOURCE=

2012-01-15 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51864

--- Comment #1 from Tobias Burnus burnus at gcc dot gnu.org 2012-01-15 
23:25:55 UTC ---
(In reply to comment #0)
 class(t), allocatable :: a(:), b(:), c(:)
 allocate(t2 :: a(3))
 allocate(t2 :: b(5))
 allocate(c(8), source=[ a, b ])

Actually, this part of the program is invalid as Fortran 2008 demands (4.8
Construction of array values):

The dynamic type of an array constructor is the same as its declared type.

Thus, one can use
 [ a, b ]
but only if both are of the declared and dynamic type t, cf.

If type-spec is omitted, each ac-value expression in the array constructor
shall have the same length type parameters; in this case, the declared type and
type parameters of the array constructor are those of the ac-value
expressions.

However, one is still allowed to use:

 [ t2 :: a, b]

in that case, a and b need to have a declared type t2 or an extension of
t2 as declared type - and can have any dynamic type.

If type-spec appears, it specifies the declared type and type parameters of
the array constructor. Each ac-value expression in the array-constructor shall
be compatible with intrinsic assignment to a variable of this type and type
parameters. Each value is converted to the type parameters of the
array-constructor in accordance with the rules of intrinsic assignment
(7.2.1.3).

And in 4.3.1.3 CLASS, one finds type compatible defined as:

A polymorphic entity that is not an unlimited polymorphic entity is type
compatible with entities of the same declared type or any of its extensions.
Even though an unlimited polymorphic entity is not considered to have a
declared type, it is type compatible with all entities. An entity is type
compatible with a type if it is type compatible with entities of that type.