]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/34760 (PRIVATE variable not allowed as STAT variable in ALLOCATE)
authorTobias Burnus <burnus@net-b.de>
Sat, 19 Jan 2008 15:41:04 +0000 (16:41 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 19 Jan 2008 15:41:04 +0000 (16:41 +0100)
2008-01-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34760
        * primary.c (match_variable): Handle FL_UNKNOWN without
        uneducated guessing.
        (match_variable): Improve error message.

2008-01-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34760
        * gfortran.dg/implicit_11.f90: New.
        * gfortran.dg/allocate_stat.f90: Update dg-error pattern.
        * gfortran.dg/entry_15.f90: Ditto.
        * gfortran.dg/func_assign.f90: Ditto.
        * gfortran.dg/gomp/reduction3.f90: Ditto.
        * gfortran.dg/proc_assign_1.f90: Ditto.

        * gfortran.dg/interface_proc_end.f90: Use dg-error instead
        of dg-excess-errors.

From-SVN: r131652

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocate_stat.f90
gcc/testsuite/gfortran.dg/entry_15.f90
gcc/testsuite/gfortran.dg/func_assign.f90
gcc/testsuite/gfortran.dg/gomp/reduction3.f90
gcc/testsuite/gfortran.dg/implicit_11.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/interface_proc_end.f90
gcc/testsuite/gfortran.dg/proc_assign_1.f90

index 736c67f131b4c0c83f84d0c25dd4057bf7951326..46c95e00f26bd751dfcd47e96bf724796e08218f 100644 (file)
@@ -1,3 +1,10 @@
+2008-01-19  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34760
+       * primary.c (match_variable): Handle FL_UNKNOWN without
+       uneducated guessing.
+       (match_variable): Improve error message.
+
 2008-01-18  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/32616
index 1d282f2b37c36482593112f097e976a178a2cdeb..4e7d4a11506dcd598479bc4d25d3ee6c9b6764b6 100644 (file)
@@ -2521,12 +2521,22 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag)
       break;
 
     case FL_UNKNOWN:
-      if (sym->attr.access == ACCESS_PUBLIC
-         || sym->attr.access == ACCESS_PRIVATE)
-       break;
-      if (gfc_add_flavor (&sym->attr, FL_VARIABLE,
-                         sym->name, NULL) == FAILURE)
-       return MATCH_ERROR;
+      {
+       sym_flavor flavor = FL_UNKNOWN;
+
+       gfc_gobble_whitespace ();
+
+       if (sym->attr.external || sym->attr.procedure
+           || sym->attr.function || sym->attr.subroutine)
+         flavor = FL_PROCEDURE;
+       else if (gfc_peek_char () != '(' || sym->ts.type != BT_UNKNOWN
+                || sym->attr.pointer || sym->as != NULL)
+         flavor = FL_VARIABLE;
+
+       if (flavor != FL_UNKNOWN
+           && gfc_add_flavor (&sym->attr, flavor, sym->name, NULL) == FAILURE)
+         return MATCH_ERROR;
+      }
       break;
 
     case FL_PARAMETER:
@@ -2553,7 +2563,7 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag)
       /* Fall through to error */
 
     default:
-      gfc_error ("Expected VARIABLE at %C");
+      gfc_error ("'%s' at %C is not a variable", sym->name);
       return MATCH_ERROR;
     }
 
index b25f7f5c38a0f64aeaf895f095d552e624d7bec3..73c1e6084a0c069e5164debad0f4f4171fe5b8cd 100644 (file)
@@ -1,3 +1,16 @@
+2008-01-19  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34760
+       * gfortran.dg/implicit_11.f90: New.
+       * gfortran.dg/allocate_stat.f90: Update dg-error pattern.
+       * gfortran.dg/entry_15.f90: Ditto.
+       * gfortran.dg/func_assign.f90: Ditto.
+       * gfortran.dg/gomp/reduction3.f90: Ditto.
+       * gfortran.dg/proc_assign_1.f90: Ditto.
+
+       * gfortran.dg/interface_proc_end.f90: Use dg-error instead
+       of dg-excess-errors.
+
 2008-01-18  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/32616
index 1361d779226ad7da8adf9a820cd8831573f0816e..94ec4303f816bebe5fa1de48c27849f2f5b5b9a7 100644 (file)
@@ -38,7 +38,7 @@ function func2() result(res)
   implicit none
   real, pointer :: gain 
   integer :: res
-  allocate (gain,STAT=func2) ! { dg-error "Expected VARIABLE" }
+  allocate (gain,STAT=func2) ! { dg-error "is not a variable" }
   deallocate(gain)
   res = 0
 end function func2
index ed0eb4b0c44578147c0c518bab4e970e66916f10..0449695e7c86af69f5033888f027f70c9c582383 100644 (file)
@@ -16,7 +16,7 @@ function func(a)
   func = a*8
   return
 entry ent(a) result(func2)
-  ent = -a*4.0 ! { dg-error "Expected VARIABLE" }
+  ent = -a*4.0 ! { dg-error "is not a variable" }
   return
 end function func
 end module m2
@@ -31,7 +31,7 @@ function func(a) result(res)
   res = a*12
   return
 entry ent(a) result(func2)
-  ent = -a*6.0 ! { dg-error "Expected VARIABLE" }
+  ent = -a*6.0 ! { dg-error "is not a variable" }
   return
 end function func
 end module m3
index 3651dfded2eeb0952c4382a7dc700d330dc79507..1f7407c7ccfe892fd2b302ae2d89c6852cf32528 100644 (file)
@@ -23,8 +23,8 @@ contains
      subroutine sub()
      end subroutine sub
    end interface
-   sub = 'a'  ! { dg-error "Expected VARIABLE" }
-   fun = 4.4  ! { dg-error "Expected VARIABLE" }
+   sub = 'a'  ! { dg-error "is not a variable" }
+   fun = 4.4  ! { dg-error "is not a variable" }
    funget = 4 ! { dg-error "is not a VALUE" }
    bar = 5    ! { dg-error "is not a VALUE" }
   end subroutine a
index 50f6450ac2f77e68fcd84ab8e0965c80463cab98..abd6d04415d23572ed4360c75a807db8bb19c549 100644 (file)
@@ -48,7 +48,7 @@ subroutine f4
   integer :: i, ior
   i = 6
 !$omp parallel reduction (ior:i)
-  ior = 4                       ! { dg-error "Expected VARIABLE" }
+  ior = 4                       ! { dg-error "is not a variable" }
 !$omp end parallel
 end subroutine f4
 subroutine f5
diff --git a/gcc/testsuite/gfortran.dg/implicit_11.f90 b/gcc/testsuite/gfortran.dg/implicit_11.f90
new file mode 100644 (file)
index 0000000..26cf5ae
--- /dev/null
@@ -0,0 +1,38 @@
+! { dg-do compile }
+! 
+! PR fortran/34760
+! The problem with implict typing is that it is unclear
+! whether an existing symbol is a variable or a function.
+! Thus it remains long FL_UNKNOWN, which causes extra 
+! problems; it was failing here since ISTAT was not
+! FL_VARIABLE but still FL_UNKNOWN.
+!
+! Test case contributed by Dick Hendrickson.
+!
+     MODULE TESTS
+       PRIVATE :: ISTAT
+       PUBLIC :: ISTAT2
+     CONTAINS
+     SUBROUTINE AD0001
+     REAL RLA1(:)
+     ALLOCATABLE RLA1
+     ISTAT = -314
+     ALLOCATE (RLA1(NF10), STAT = ISTAT)
+     ALLOCATE (RLA1(NF10), STAT = ISTAT2)
+     END SUBROUTINE
+     END MODULE
+
+     MODULE TESTS2
+       PRIVATE :: ISTAT2
+     CONTAINS
+     function istat2()
+       istat2 = 0
+     end function istat2
+     SUBROUTINE AD0001
+       REAL RLA1(:)
+       ALLOCATABLE RLA1
+       ALLOCATE (RLA1(NF10), STAT = ISTAT2) ! { dg-error "must be a variable" }
+     END SUBROUTINE
+     END MODULE tests2
+
+! { dg-final { cleanup-modules "TESTS" } }
index d037de694a52358e494a275356fc20ea5734c9af..c6ea2b9e032c70d994918d24ad3729647211e70f 100644 (file)
@@ -16,4 +16,4 @@
       END INTERFACE
       end ! { dg-error "END SUBROUTINE statement" }
       end module ! { dg-error "END SUBROUTINE statement" }
-! { dg-excess-errors "Unexpected end of file" }
+! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 }
index 418e5f49e86cbe6688309a858fd31f72bb7ed475..9f2952b5d03d848aa177a32fafbcd600969d413d 100644 (file)
@@ -58,12 +58,12 @@ end module simpler
     end interface\r
     stmt_fcn (w) = sin (w)     \r
     call x (y ())\r
-    x = 10                   ! { dg-error "Expected VARIABLE" }\r
+    x = 10                   ! { dg-error "is not a variable" }\r
     y = 20                   ! { dg-error "is not a VALUE" }\r
     foo_er = 8               ! { dg-error "is not a VALUE" }\r
     ext1 = 99                ! { dg-error "is not a VALUE" }\r
     ext2 = 99                ! { dg-error "is not a VALUE" }\r
-    stmt_fcn = 1.0           ! { dg-error "Expected VARIABLE" }\r
+    stmt_fcn = 1.0           ! { dg-error "is not a variable" }\r
     w = stmt_fcn (1.0)\r
 contains\r
     subroutine x (i)\r