]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/34514 (Accepts invalid: Dimensions specified for N after initialisation)
authorTobias Burnus <burnus@net-b.de>
Tue, 25 Dec 2007 12:05:23 +0000 (13:05 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Tue, 25 Dec 2007 12:05:23 +0000 (13:05 +0100)
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  Tobias Burnus  <burnus@net-b.de>

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

From-SVN: r131169

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

index 7ffa51d1516118cfcc51900d4a2a35eea1629167..3e16f9bd5a8f255ce0c5457ad2052a377a0a89e5 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 072477ef3ac1eb3241e8b7bc32f50b96b4c2ff0c..dd8eb35ae6b5e456e23522344f80cf8bffa33963 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 4bfd5232c203c2360c02c0685411edc2f0274414..069733d071299578f6b56a8aaedcbaad22fc44bc 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