Commit da285ce8 by Janus Weil

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
parent 5cbf5c20
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> 2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565 PR fortran/47565
......
...@@ -10063,7 +10063,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) ...@@ -10063,7 +10063,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
/* Reject illegal initializers. */ /* Reject illegal initializers. */
if (!sym->mark && sym->value) 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", gfc_error ("Allocatable '%s' at %L cannot have an initializer",
sym->name, &sym->declared_at); sym->name, &sym->declared_at);
else if (sym->attr.external) else if (sym->attr.external)
......
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> 2011-02-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47566 PR tree-optimization/47566
......
! { 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
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