decl.c (variable_decl): Always apply default initializer.
authorVictor Leikehman <lei@haifasphere.co.il>
Fri, 14 May 2004 22:52:04 +0000 (01:52 +0300)
committerPaul Brook <pbrook@gcc.gnu.org>
Fri, 14 May 2004 22:52:04 +0000 (22:52 +0000)
fortran/
* decl.c (variable_decl): Always apply default initializer.
libgfortran/
* gfortran.fortran-torture/execute/def_init_3.f90: New test.

From-SVN: r81865

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 [new file with mode: 0644]

index 605a5726b05fa63e17365088e845585a48fd3d1e..19a66ce588a7d78eaa9d624b23df8d4bd93e68a8 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-14  Victor Leikehman  <lei@haifasphere.co.il>
+
+       * decl.c (variable_decl): Always apply default initializer.
+
 2004-05-08  Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/15206
index 9d6bf948dd7f1f94db3e55fc181fa816d3901910..2aed9b248d6f7c3b41fb25fe6ec810e3ae38f2f8 100644 (file)
@@ -619,10 +619,11 @@ variable_decl (void)
          if (m != MATCH_YES)
            goto cleanup;
        }
-      else if (current_ts.type == BT_DERIVED)
-        {
-          initializer = default_initializer ();
-        }
+    }
+
+  if (current_ts.type == BT_DERIVED && !initializer)
+    {
+      initializer = default_initializer ();
     }
 
   /* Add the initializer.  Note that it is fine if &initializer is
index 77a80bad099a14f2b950e017643f30597e658d81..7e14671867298b257bc0125c622eee7547133efd 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-14  Victor Leikehman  <lei@haifasphere.co.il>
+
+       * gfortran.fortran-torture/execute/def_init_3.f90: New test.
+
 2004-05-14  Jeff Law  <law@redhat.com>
 
        * gcc.dg/tree-ssa/20040514-2.c: New test.
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90
new file mode 100644 (file)
index 0000000..16f203a
--- /dev/null
@@ -0,0 +1,12 @@
+! PR15365
+! Default initializers were being missed
+program main
+  type xyz
+     integer :: x = 123
+  end
+
+  type (xyz) :: a  !! ok
+  type (xyz) b    !!! not initialized !!!
+  if (a%x.ne.123) call abort
+  if (b%x.ne.123) call abort
+end