summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-02 13:11:50 +0000
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-02 13:11:50 +0000
commitea108448cb016a35692dd795209f7a7344c38d01 (patch)
tree61cdc6bbaf1a36bf6e300c2019dba35ce8db3ef4
parentf6c35aa46abc8a18ed2b0fdc5481e41f13f549bf (diff)
downloadgcc-ea108448cb016a35692dd795209f7a7344c38d01.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169520 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/resolve.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/class_36.f0314
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index bb1d89e49fc..2331b973e00 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2a0fc49571c..7f3734e8269 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4040f63e79a..6b460a10efe 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/class_36.f03 b/gcc/testsuite/gfortran.dg/class_36.f03
new file mode 100644
index 00000000000..6911f3f04b6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_36.f03
@@ -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