OSDN Git Service

2010-02-27 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 27 Feb 2010 17:25:05 +0000 (17:25 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 27 Feb 2010 17:25:05 +0000 (17:25 +0000)
        PR fortran/43185
        * resolve.c (resolve_fl_variable_derived): Imply SAVE
        for module variables for Fortran 2008.

2010-02-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/43185
        * gfortran.dg/default_initialization_1.f90: Add -std=f2003.
        * gfortran.dg/default_initialization_4.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157109 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/default_initialization_1.f90
gcc/testsuite/gfortran.dg/default_initialization_4.f90 [new file with mode: 0644]

index 08a6b68..e5d7224 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-27  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/43185
+       * resolve.c (resolve_fl_variable_derived): Imply SAVE
+       for module variables for Fortran 2008.
+
 2010-02-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/43166
index bcc8eae..4f9eb01 100644 (file)
@@ -8937,13 +8937,12 @@ resolve_fl_variable_derived (gfc_symbol *sym, int no_init_flag)
       && sym->ns->proc_name->attr.flavor == FL_MODULE
       && !sym->ns->save_all && !sym->attr.save
       && !sym->attr.pointer && !sym->attr.allocatable
-      && has_default_initializer (sym->ts.u.derived))
-    {
-      gfc_error("Object '%s' at %L must have the SAVE attribute for "
-               "default initialization of a component",
-               sym->name, &sym->declared_at);
-      return FAILURE;
-    }
+      && has_default_initializer (sym->ts.u.derived)
+      && gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Implied SAVE for "
+                        "module variable '%s' at %L, needed due to "
+                        "the default initialization", sym->name,
+                        &sym->declared_at) == FAILURE)
+    return FAILURE;
 
   if (sym->ts.type == BT_CLASS)
     {
index bc56a66..6de1a8b 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-27  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/43185
+       * gfortran.dg/default_initialization_1.f90: Add -std=f2003.
+       * gfortran.dg/default_initialization_4.f90: New test.
+
 2010-02-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/thin_pointer.ad[sb]: Rename into...
index fe67e2f..b03b698 100644 (file)
@@ -1,6 +1,7 @@
 !
 ! { dg-do compile }
-! PR 20845
+! { dg-options "-std=f2003" }
+! PR 20845; for F2008: PR fortran/43185
 !
 ! In ISO/IEC 1539-1:1997(E), 4th constraint in section 11.3:
 !
diff --git a/gcc/testsuite/gfortran.dg/default_initialization_4.f90 b/gcc/testsuite/gfortran.dg/default_initialization_4.f90
new file mode 100644 (file)
index 0000000..7a15ba2
--- /dev/null
@@ -0,0 +1,22 @@
+!
+! { dg-do run }
+!
+! PR fortran/43185
+!
+! The following is valid F2008 but not valid Fortran 90/2003
+! Cf. PR 20845
+!
+module good
+   implicit none
+   type default_initialization
+      integer :: x = 42
+   end type default_initialization
+   type (default_initialization) t ! OK in F2008
+end module good
+
+use good
+if (t%x /= 42) call abort()
+t%x = 0
+if (t%x /= 0) call abort()
+end
+! { dg-final { cleanup-modules "good" } }