Commit 40a778bd by Paul Thomas

re PR fortran/62044 (ICE in USE statement with RENAME for extended derived type)

2015-01-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/62044
	* resolve.c (resolve_allocate_expr): If the default initializer
	is NULL, keep the original MOLD expression so that the correct
	typespec is available.

2015-01-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/62044
	* gfortran.dg/allocate_with_mold_1.f90: New test

From-SVN: r220140
parent 1b7706c8
2015-01-26 Paul Thomas <pault@gcc.gnu.org>
PR fortran/62044
* resolve.c (resolve_allocate_expr): If the default initializer
is NULL, keep the original MOLD expression so that the correct
typespec is available.
2015-01-26 Tobias Burnus <burnus@net-b.de> 2015-01-26 Tobias Burnus <burnus@net-b.de>
PR fortran/64771 PR fortran/64771
......
...@@ -6995,9 +6995,12 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code) ...@@ -6995,9 +6995,12 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
{ {
/* Default initialization via MOLD (non-polymorphic). */ /* Default initialization via MOLD (non-polymorphic). */
gfc_expr *rhs = gfc_default_initializer (&code->expr3->ts); gfc_expr *rhs = gfc_default_initializer (&code->expr3->ts);
gfc_resolve_expr (rhs); if (rhs != NULL)
gfc_free_expr (code->expr3); {
code->expr3 = rhs; gfc_resolve_expr (rhs);
gfc_free_expr (code->expr3);
code->expr3 = rhs;
}
} }
if (e->ts.type == BT_CLASS && !unlimited && !UNLIMITED_POLY (code->expr3)) if (e->ts.type == BT_CLASS && !unlimited && !UNLIMITED_POLY (code->expr3))
......
2015-01-26 Paul Thomas <pault@gcc.gnu.org>
PR fortran/62044
* gfortran.dg/allocate_with_mold_1.f90: New test
2015-01-26 Jakub Jelinek <jakub@redhat.com> 2015-01-26 Jakub Jelinek <jakub@redhat.com>
PR c/64778 PR c/64778
......
! { dg-do run }
!
! Fixes a bug that emerged from the fix of PR62044 - see the PR. When
! there was no default initializer, code-expr3 was set null and so the
! vpointer was set to the vtable of the declared type, rather than that
! of the MOLD expression.
!
! Contributed by but based on the original PR62044 testcase by
! Paul Thomas <pault@gcc.gnu.org>
!
module GridImageSilo_Template
implicit none
type, public, abstract :: GridImageSiloTemplate
end type GridImageSiloTemplate
end module GridImageSilo_Template
module UnstructuredGridImageSilo_Form
use GridImageSilo_Template
implicit none
type, public, extends ( GridImageSiloTemplate ) :: &
UnstructuredGridImageSiloForm
end type UnstructuredGridImageSiloForm
end module UnstructuredGridImageSilo_Form
module UnstructuredGridImages
use UnstructuredGridImageSilo_Form, &
UnstructuredGridImageForm => UnstructuredGridImageSiloForm
contains
subroutine foo
class (GridImageSiloTemplate), allocatable :: a
type (UnstructuredGridImageForm) :: b
integer :: i = 0
allocate (a, mold = b)
select type (a)
type is (UnstructuredGridImageForm)
i = 1
class default
i = 2
end select
if (i .ne. 1) call abort
end subroutine
end module UnstructuredGridImages
use UnstructuredGridImages
call foo
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment