Commit for Asher Langton <langton2@llnl.gov>
authorAsher Langton <langton2@llnl.gov>
Mon, 24 Oct 2005 14:50:18 +0000 (14:50 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Mon, 24 Oct 2005 14:50:18 +0000 (14:50 +0000)
fortran/
        * decl.c (gfc_match_save): Changed duplicate SAVE errors to
        warnings in the absence of strict standard conformance
        * symbol.c (gfc_add_save): Same.

testsuite/
* gfortran.dg/dup_save_1.f90: New test.
* gfortran.dg/dup_save_2.f90: New test.

From-SVN: r105850

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dup_save_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/dup_save_2.f90 [new file with mode: 0644]

index 5cb021b391f20ad238fbbfc8d883e7416686b086..a019a1b25126fa707d666fe9cc7f8b2ba0554dec 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-24  Asher Langton  <langton2@llnl.gov>
+
+       * decl.c (gfc_match_save): Changed duplicate SAVE errors to
+       warnings in the absence of strict standard conformance
+       * symbol.c (gfc_add_save): Same.
+
 2005-10-24  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/15586
index 69c0fc87162d92683a3218a7f710bad4a3b78c01..2ecd143190b7a5429e476dab9877232bc377b0a6 100644 (file)
@@ -3271,10 +3271,11 @@ gfc_match_save (void)
     {
       if (gfc_current_ns->seen_save)
        {
-         gfc_error ("Blanket SAVE statement at %C follows previous "
-                    "SAVE statement");
-
-         return MATCH_ERROR;
+         if (gfc_notify_std (GFC_STD_LEGACY, 
+                             "Blanket SAVE statement at %C follows previous "
+                             "SAVE statement")
+             == FAILURE)
+           return MATCH_ERROR;
        }
 
       gfc_current_ns->save_all = gfc_current_ns->seen_save = 1;
@@ -3283,8 +3284,10 @@ gfc_match_save (void)
 
   if (gfc_current_ns->save_all)
     {
-      gfc_error ("SAVE statement at %C follows blanket SAVE statement");
-      return MATCH_ERROR;
+      if (gfc_notify_std (GFC_STD_LEGACY, 
+                         "SAVE statement at %C follows blanket SAVE statement")
+         == FAILURE)
+       return MATCH_ERROR;
     }
 
   gfc_match (" ::");
index 98ce66fef98da861af621e6b7bb83214ae780b5f..c1221eb72a52afb26452c725481fc9869ecbc87c 100644 (file)
@@ -681,8 +681,11 @@ gfc_add_save (symbol_attribute * attr, const char *name, locus * where)
 
   if (attr->save)
     {
-      duplicate_attr ("SAVE", where);
-      return FAILURE;
+       if (gfc_notify_std (GFC_STD_LEGACY, 
+                           "Duplicate SAVE attribute specified at %L",
+                           where) 
+           == FAILURE)
+         return FAILURE;
     }
 
   attr->save = 1;
index 3f575da056d3abbb17fe15e9f1d82bdc9f650ed3..e8f970349f6d96df253efe8434b38c2521ad42d5 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-24  Asher Langton  <langton2@llnl.gov>
+
+       * gfortran.dg/dup_save_1.f90: New test.
+       * gfortran.dg/dup_save_2.f90: New test.
+
 2005-10-24  Paul Brook  <paul@codesourcery.com>
 
        PR 24107
@@ -6,8 +11,8 @@
 
 2005-10-23  Jerry DeLisle  <jvdelisle@verizon.net>
 
-        PR libgfortran/24489
-        * gfortran.dg/pr24489.f90: New test.
+       PR libgfortran/24489
+       * gfortran.dg/pr24489.f90: New test.
 
 2005-10-23  Andrew Pinski  <pinskia@physics.uc.edu>
 
diff --git a/gcc/testsuite/gfortran.dg/dup_save_1.f90 b/gcc/testsuite/gfortran.dg/dup_save_1.f90
new file mode 100644 (file)
index 0000000..d7ce8e1
--- /dev/null
@@ -0,0 +1,57 @@
+! { dg-do run }
+program save_1
+  implicit none
+  integer i
+  integer foo1, foo2, foo3, foo4
+  do i=1,10
+     if (foo1().ne.i) then
+        call abort
+     end if
+     if (foo2().ne.i) then
+        call abort
+     end if
+     if (foo3().ne.i) then
+        call abort
+     end if
+     if (foo4().ne.i) then
+        call abort
+     end if
+  end do
+end program save_1
+
+integer function foo1
+  integer j
+  save
+  save ! { dg-warning "Blanket SAVE" }
+  data j /0/
+  j = j + 1
+  foo1 = j
+end function foo1
+
+integer function foo2
+  integer j
+  save j
+  save j ! { dg-warning "Duplicate SAVE" }
+  data j /0/
+  j = j + 1
+  foo2 = j
+end function foo2
+
+integer function foo3
+  integer j ! { dg-warning "Duplicate SAVE" }
+  save
+  save j ! { dg-warning "SAVE statement" }
+  data j /0/
+  j = j + 1
+  foo3 = j
+end function foo3
+
+integer function foo4
+  integer j ! { dg-warning "Duplicate SAVE" }
+  save j
+  save
+  data j /0/
+  j = j + 1
+  foo4 = j
+end function foo4
+
diff --git a/gcc/testsuite/gfortran.dg/dup_save_2.f90 b/gcc/testsuite/gfortran.dg/dup_save_2.f90
new file mode 100644 (file)
index 0000000..1c0bfdb
--- /dev/null
@@ -0,0 +1,57 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+program save_2
+  implicit none
+  integer i
+  integer foo1, foo2, foo3, foo4
+  do i=1,10
+     if (foo1().ne.i) then
+        call abort
+     end if
+     if (foo2().ne.i) then
+        call abort
+     end if
+     if (foo3().ne.i) then
+        call abort
+     end if
+     if (foo4().ne.i) then
+        call abort
+     end if
+  end do
+end program save_2
+
+integer function foo1
+  integer j
+  save
+  save ! { dg-error "Blanket SAVE" }
+  data j /0/
+  j = j + 1
+  foo1 = j
+end function foo1
+
+integer function foo2
+  integer j
+  save j
+  save j ! { dg-error "Duplicate SAVE" }
+  data j /0/
+  j = j + 1
+  foo2 = j
+end function foo2
+
+integer function foo3
+  integer j
+  save
+  save j ! { dg-error "SAVE statement" }
+  data j /0/
+  j = j + 1
+  foo3 = j
+end function foo3
+
+integer function foo4
+  integer j ! { dg-error "Duplicate SAVE" }
+  save j
+  save
+  data j /0/
+  j = j + 1
+  foo4 = j
+end function foo4