aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2012-01-29 21:51:19 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2012-01-29 21:51:19 +0100
commit0b673c092d05972aba4b99a47b4aea039f022d79 (patch)
tree3a7105a717a7135837ca23018baeaa96120e3127
parentcc19bc7fdd93110ad07d6a6e2e28bdc974593df8 (diff)
downloadgcc-0b673c092d05972aba4b99a47b4aea039f022d79.zip
gcc-0b673c092d05972aba4b99a47b4aea039f022d79.tar.gz
gcc-0b673c092d05972aba4b99a47b4aea039f022d79.tar.bz2
re PR fortran/41600 ([OOP] SELECT TYPE with associate-name => exp: Arrays not supported)
2012-01-29 Tobias Burnus <burnus@net-b.de> PR fortran/41600 * expr.c (gfc_default_initializer): Convert the values if the type does not match. 2012-01-29 Tobias Burnus <burnus@net-b.de> PR fortran/41600 * gfortran.dg/default_initialization_6.f90: New. Co-Authored-By: Steven G. Kargl <kargl@gcc.gnu.org> From-SVN: r183682
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/expr.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/default_initialization_6.f9011
4 files changed, 30 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 6b45348..3fb70e0 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -12,6 +12,12 @@
2012-01-29 Tobias Burnus <burnus@net-b.de>
+ PR fortran/41600
+ * expr.c (gfc_default_initializer): Convert the values if
+ the type does not match.
+
+2012-01-29 Tobias Burnus <burnus@net-b.de>
+
PR fortran/51972
* trans-array.c (structure_alloc_comps): Fix assignment of
polymorphic components (polymorphic deep copying).
@@ -194,7 +200,7 @@
PR fortran/50556
* symbol.c (check_conflict): namelist-group-name cannot have the SAVE
- attribure.
+ attribute.
2012-01-21 Tobias Burnus <burnus@net-b.de>
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index c401313..129ece3 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3774,7 +3774,13 @@ gfc_default_initializer (gfc_typespec *ts)
gfc_constructor *ctor = gfc_constructor_get();
if (comp->initializer)
- ctor->expr = gfc_copy_expr (comp->initializer);
+ {
+ ctor->expr = gfc_copy_expr (comp->initializer);
+ if ((comp->ts.type != comp->initializer->ts.type
+ || comp->ts.kind != comp->initializer->ts.kind)
+ && !comp->attr.pointer && !comp->attr.proc_pointer)
+ gfc_convert_type_warn (ctor->expr, &comp->ts, 2, false);
+ }
if (comp->attr.allocatable
|| (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f0ecfab..284affa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2012-01-29 Tobias Burnus <burnus@net-b.de>
+ PR fortran/41600
+ * gfortran.dg/default_initialization_6.f90: New.
+
+2012-01-29 Tobias Burnus <burnus@net-b.de>
+
PR fortran/51972
* gfortran.dg/class_allocate_12.f90: Enable disabled test.
* gfortran.dg/class_48.f90: New.
diff --git a/gcc/testsuite/gfortran.dg/default_initialization_6.f90 b/gcc/testsuite/gfortran.dg/default_initialization_6.f90
new file mode 100644
index 0000000..6af65bc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/default_initialization_6.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR fortran/41600
+!
+ implicit none
+ type t
+ integer :: X = -999.0
+ end type t
+ class(t), allocatable :: y(:)
+ allocate (t :: y(1))
+end