re PR fortran/41600 ([OOP] SELECT TYPE with associate-name => exp: Arrays not supported)
authorTobias Burnus <burnus@net-b.de>
Sun, 29 Jan 2012 20:51:19 +0000 (21:51 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 29 Jan 2012 20:51:19 +0000 (21:51 +0100)
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

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/default_initialization_6.f90 [new file with mode: 0644]

index 6b45348c417ff3b585a676162a85bf7c62a5a936..3fb70e0c12e63c70c02b422fd33891d4bfd12908 100644 (file)
        (write_blank_common): Call write_atom directly.
        (write_symbol): Likewise.
 
+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
 
        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>
 
index c4013133560cc7c2e385af3fa1b21b85bb8b0581..129ece355071546683e24ec4c81551c1f65114a1 100644 (file)
@@ -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))
index f0ecfab3f25805fdf309b72485ded6c7d7bc872f..284affa83c5f579ab7aab99392bbf46aefb90b8b 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/default_initialization_6.f90 b/gcc/testsuite/gfortran.dg/default_initialization_6.f90
new file mode 100644 (file)
index 0000000..6af65bc
--- /dev/null
@@ -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