OSDN Git Service

2007-12-25 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Dec 2007 12:05:23 +0000 (12:05 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Dec 2007 12:05:23 +0000 (12:05 +0000)
        PR fortran/34514
        * decl.c (attr_decl1): Reject specifying the DIMENSION for
        already initialized variable.
        (do_parm): Reject PARAMETER for already initialized variable.

2007-12-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34514
        * gfortran.dg/initialization_17.f90: New.

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

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

index 7ffa51d..3e16f9b 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-25  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34514
+       * decl.c (attr_decl1): Reject specifying the DIMENSION for
+       already initialized variable.
+       (do_parm): Reject PARAMETER for already initialized variable.
+
 2007-12-25  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/34533
index 072477e..dd8eb35 100644 (file)
@@ -5151,6 +5151,14 @@ attr_decl1 (void)
          goto cleanup;
        }
 
+      if (current_attr.dimension && sym->value)
+       {
+         gfc_error ("Dimensions specified for %s at %L after its "
+                    "initialisation", sym->name, &var_locus);
+         m = MATCH_ERROR;
+         goto cleanup;
+       }
+
       if ((current_attr.allocatable || current_attr.pointer)
          && (m == MATCH_YES) && (as->type != AS_DEFERRED))
        {
@@ -5753,6 +5761,13 @@ do_parm (void)
       goto cleanup;
     }
 
+  if (sym->value)
+    {
+      gfc_error ("Initializing already initialized variable at %C");
+      m = MATCH_ERROR;
+      goto cleanup;
+    }
+
   if (sym->ts.type == BT_CHARACTER
       && sym->ts.cl != NULL
       && sym->ts.cl->length != NULL
index 4bfd523..069733d 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-25  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34514
+       * gfortran.dg/initialization_17.f90: New.
+
 2007-12-25  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR libfortran/34566
diff --git a/gcc/testsuite/gfortran.dg/initialization_17.f90 b/gcc/testsuite/gfortran.dg/initialization_17.f90
new file mode 100644 (file)
index 0000000..c7b73b5
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+!
+! PR fortran/34514
+!
+! Initialization and typespec changes.
+!
+integer :: n = 5, m = 7
+parameter (n = 42) ! { dg-error "Initializing already initialized variable" }
+dimension :: m(3)  ! { dg-error "after its initialisation" } 
+end