gfortran.h (gfc_namespace): Add seen_implicit_none field.
authorTobias Schlüter <tobi@gcc.gnu.org>
Fri, 29 Apr 2005 00:13:08 +0000 (02:13 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Fri, 29 Apr 2005 00:13:08 +0000 (02:13 +0200)
fortran/
* gfortran.h (gfc_namespace): Add seen_implicit_none field.
* symbol.c (gfc_set_implicit_none): Give error if there's a previous
IMPLICIT NONE, set seen_implicit_none.
(gfc_merge_new_implicit): Error if there's an IMPLICIT NONE statement.
testsuite/
* gfortran.dg/implicit_4.f90: New test.

From-SVN: r98952

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

index 8d8e000e15a714462d052b3f04741f9a628f195d..7ef40e0cdaef1aba5e856ce4aeafaa95a7f08013 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-29  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * gfortran.h (gfc_namespace): Add seen_implicit_none field.
+       * symbol.c (gfc_set_implicit_none): Give error if there's a previous
+       IMPLICIT NONE, set seen_implicit_none.
+       (gfc_merge_new_implicit): Error if there's an IMPLICIT NONE statement.
+
 2005-04-28  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.h (gfc_gsymbol): Make name a const char *.
index 6906b81cc23de33dc2a1524a77c7717800b12bc8..5fb9f53db8781d1d6948ecdd1f6d2a8b9206b052 100644 (file)
@@ -106,6 +106,14 @@ gfc_set_implicit_none (void)
 {
   int i;
 
+  if (gfc_current_ns->seen_implicit_none)
+    {
+      gfc_error ("Duplicate IMPLICIT NONE statement at %C");
+      return;
+    }
+
+  gfc_current_ns->seen_implicit_none = 1;
+
   for (i = 0; i < GFC_LETTERS; i++)
     {
       gfc_clear_ts (&gfc_current_ns->default_type[i]);
@@ -160,6 +168,12 @@ gfc_merge_new_implicit (gfc_typespec * ts)
 {
   int i;
 
+  if (gfc_current_ns->seen_implicit_none)
+    {
+      gfc_error ("Cannot specify IMPLICIT at %C after IMPLICIT NONE");
+      return FAILURE;
+    }
+
   for (i = 0; i < GFC_LETTERS; i++)
     {
       if (new_flag[i])
index 41354462589a0073ef1c2ddac49b9107decefe74..0ab6998a33a03a4541e73432a84b5cff7ef924fe 100644 (file)
@@ -1,9 +1,13 @@
-2004-04-28  Bob Wilson  <bob.wilson@acm.org>
+2005-04-29  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * gfortran.dg/implicit_4.f90: New test.
+
+2005-04-28  Bob Wilson  <bob.wilson@acm.org>
 
        * lib/target-supports.exp (check_profiling_available): Return
        false for xtensa-*-elf.
 
-2004-04-29  David Billinghurst (David.Billinghurst@riotinto.com)
+2005-04-29  David Billinghurst (David.Billinghurst@riotinto.com)
 
        * lib/fortran-torture.exp (fortran-torture.exp): Catch
        error if file cannot be deleted.
diff --git a/gcc/testsuite/gfortran.dg/implicit_4.f90 b/gcc/testsuite/gfortran.dg/implicit_4.f90
new file mode 100644 (file)
index 0000000..2e871b0
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! Verify error diagnosis for invalid combinations of IMPLICIT statements
+IMPLICIT NONE
+IMPLICIT NONE ! { dg-error "Duplicate" }
+END
+
+SUBROUTINE a
+IMPLICIT REAL(b-j) ! { dg-error "cannot follow" }
+implicit none      ! { dg-error "cannot follow" }
+END SUBROUTINE a
+
+subroutine b
+implicit none
+implicit real(g-k) ! { dg-error "Cannot specify" }
+end subroutine b
+
+subroutine c
+implicit real(a-b)
+implicit integer (b-c) ! { dg-error "already" }
+implicit real(d-f), complex(f-g) ! { dg-error "already" }
+end subroutine c