re PR fortran/47572 ([OOP] Invalid: Allocatable polymorphic with init expression.)

2011-02-02  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47572
	* resolve.c (resolve_fl_variable): Handle polymorphic allocatables.


2011-02-02  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47572
	* gfortran.dg/class_36.f03: New.

From-SVN: r169520
This commit is contained in:
Janus Weil 2011-02-02 14:11:50 +01:00
parent 5cbf5c20cf
commit da285ce8e4
4 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-02-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/47572
* resolve.c (resolve_fl_variable): Handle polymorphic allocatables.
2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565

View File

@ -10063,7 +10063,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
/* Reject illegal initializers. */
if (!sym->mark && sym->value)
{
if (sym->attr.allocatable)
if (sym->attr.allocatable || (sym->ts.type == BT_CLASS
&& CLASS_DATA (sym)->attr.allocatable))
gfc_error ("Allocatable '%s' at %L cannot have an initializer",
sym->name, &sym->declared_at);
else if (sym->attr.external)

View File

@ -1,3 +1,8 @@
2011-02-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/47572
* gfortran.dg/class_36.f03: New.
2011-02-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47566

View File

@ -0,0 +1,14 @@
! { dg-do compile }
!
! PR 47572: [OOP] Invalid: Allocatable polymorphic with init expression.
!
! Contributed by Edmondo Giovannozzi <edmondo.giovannozzi@gmail.com>
! cf. http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/763785b16883ed68
program scalar_allocation
type test
real :: a
end type
class (test), allocatable :: b = test(3.4) ! { dg-error "cannot have an initializer" }
print *,allocated(b)
end program