fortran/
authortobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 7 Jan 2006 16:30:53 +0000 (16:30 +0000)
committertobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 7 Jan 2006 16:30:53 +0000 (16:30 +0000)
* decl.c (gfc_match_function_decl): Correctly error out in case of
omitted function argument list.
testsuite/
* gfortran.dg/func_decl_1.f90: New.
* gfortran.dg/array_alloc_1.f90: Fix wrong function declaration.
* gfortran.dg/array_alloc_2.f90: Likewise.
* gfortran.dg/char_result_8.f90: Likewise.
* gfortran.dg/dup_save_1.f90: Likewise.
* gfortran.dg/dup_save_2.f90: Likewise.
* gfortran.dg/f2c_6.f90: Likewise.
* gfortran.dg/f2c_7.f90: Likewise.
* gfortran.dg/func_result_2.f90: Likewise.
* gfortran.fortran-torture/execute/pr23373-2.f90: Likewise.

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

13 files changed:
gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/array_alloc_1.f90
gcc/testsuite/gfortran.dg/array_alloc_2.f90
gcc/testsuite/gfortran.dg/char_result_8.f90
gcc/testsuite/gfortran.dg/dup_save_1.f90
gcc/testsuite/gfortran.dg/dup_save_2.f90
gcc/testsuite/gfortran.dg/f2c_6.f90
gcc/testsuite/gfortran.dg/f2c_7.f90
gcc/testsuite/gfortran.dg/func_decl_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/func_result_2.f90
gcc/testsuite/gfortran.fortran-torture/execute/pr23373-2.f90

index ea08640..112fc36 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-07  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * decl.c (gfc_match_function_decl): Correctly error out in case of
+       omitted function argument list.
+
 2006-01-07  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/22146
index 1358cdc..1d20a0d 100644 (file)
@@ -2548,7 +2548,12 @@ gfc_match_function_decl (void)
 
   m = gfc_match_formal_arglist (sym, 0, 0);
   if (m == MATCH_NO)
-    gfc_error ("Expected formal argument list in function definition at %C");
+    {
+      gfc_error ("Expected formal argument list in function "
+                "definition at %C");
+      m = MATCH_ERROR;
+      goto cleanup;
+    }
   else if (m == MATCH_ERROR)
     goto cleanup;
 
index 7a0e309..12d45c8 100644 (file)
@@ -1,3 +1,16 @@
+2005-01-07  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * gfortran.dg/func_decl_1.f90: New.
+       * gfortran.dg/array_alloc_1.f90: Fix wrong function declaration.
+       * gfortran.dg/array_alloc_2.f90: Likewise.
+       * gfortran.dg/char_result_8.f90: Likewise.
+       * gfortran.dg/dup_save_1.f90: Likewise.
+       * gfortran.dg/dup_save_2.f90: Likewise.
+       * gfortran.dg/f2c_6.f90: Likewise.
+       * gfortran.dg/f2c_7.f90: Likewise.
+       * gfortran.dg/func_result_2.f90: Likewise.
+       * gfortran.fortran-torture/execute/pr23373-2.f90: Likewise.
+
 2006-01-07  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/22146
index 86e69e0..17be757 100644 (file)
@@ -13,7 +13,7 @@ contains
     end do
   end subroutine test
 
-  function f
+  function f ()
     integer, dimension (10) :: f
     integer :: i
     forall (i = 1:10) f (i) = i * 100
index 5381bf4..a225854 100644 (file)
@@ -17,7 +17,7 @@ contains
     end do
   end subroutine test
 
-  function f1
+  function f1 ()
     integer, dimension (n) :: f1
     integer :: i
     forall (i = 1:n) f1 (i) = i * 100
index b1dda89..4da9feb 100644 (file)
@@ -13,7 +13,7 @@ program main
 
   call indirect (100)
 contains
-  function f1
+  function f1 ()
     character (len = 30) :: f1
     f1 = ''
   end function f1
@@ -24,7 +24,7 @@ contains
     f2 = ''
   end function f2
 
-  function f3
+  function f3 ()
     character (len = 30), pointer :: f3
     f3 => string
   end function f3
index d7ce8e1..7f22b62 100644 (file)
@@ -19,7 +19,7 @@ program save_1
   end do
 end program save_1
 
-integer function foo1
+integer function foo1 ()
   integer j
   save
   save ! { dg-warning "Blanket SAVE" }
@@ -28,7 +28,7 @@ integer function foo1
   foo1 = j
 end function foo1
 
-integer function foo2
+integer function foo2 ()
   integer j
   save j
   save j ! { dg-warning "Duplicate SAVE" }
@@ -37,7 +37,7 @@ integer function foo2
   foo2 = j
 end function foo2
 
-integer function foo3
+integer function foo3 ()
   integer j ! { dg-warning "Duplicate SAVE" }
   save
   save j ! { dg-warning "SAVE statement" }
@@ -46,7 +46,7 @@ integer function foo3
   foo3 = j
 end function foo3
 
-integer function foo4
+integer function foo4 ()
   integer j ! { dg-warning "Duplicate SAVE" }
   save j
   save
index 1c0bfdb..3a24bdc 100644 (file)
@@ -20,7 +20,7 @@ program save_2
   end do
 end program save_2
 
-integer function foo1
+integer function foo1 ()
   integer j
   save
   save ! { dg-error "Blanket SAVE" }
@@ -29,7 +29,7 @@ integer function foo1
   foo1 = j
 end function foo1
 
-integer function foo2
+integer function foo2 ()
   integer j
   save j
   save j ! { dg-error "Duplicate SAVE" }
@@ -38,7 +38,7 @@ integer function foo2
   foo2 = j
 end function foo2
 
-integer function foo3
+integer function foo3 ()
   integer j
   save
   save j ! { dg-error "SAVE statement" }
@@ -47,7 +47,7 @@ integer function foo3
   foo3 = j
 end function foo3
 
-integer function foo4
+integer function foo4 ()
   integer j ! { dg-error "Duplicate SAVE" }
   save j
   save
index b276b3d..d28724c 100644 (file)
@@ -38,22 +38,22 @@ function f() result(r)
 end function f
 
 interface
-   function c
+   function c ()
      complex, pointer :: c
    end function c
 end interface
 interface
-   function d
+   function d()
      complex, pointer :: d
    end function d
 end interface
 interface
-   function e result(r)
+   function e () result(r)
      complex, pointer :: r
    end function e
 end interface
 interface
-   function f result(r)
+   function f () result(r)
      complex, pointer :: r
    end function f
 end interface
index c15ff7a..d67e10b 100644 (file)
@@ -17,12 +17,12 @@ end function d
 
 subroutine test_without_result
 interface
-   function c
+   function c ()
      complex :: c(5)
    end function c
 end interface
 interface
-   function d
+   function d ()
      complex :: d(5)
    end function d
 end interface
@@ -35,12 +35,12 @@ end subroutine test_without_result
 
 subroutine test_with_result
 interface
-   function c result(r)
+   function c () result(r)
      complex :: r(5)
    end function c
 end interface
 interface
-   function d result(r)
+   function d () result(r)
      complex :: r(5)
    end function d
 end interface
diff --git a/gcc/testsuite/gfortran.dg/func_decl_1.f90 b/gcc/testsuite/gfortran.dg/func_decl_1.f90
new file mode 100644 (file)
index 0000000..c5576ef
--- /dev/null
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! we didn't correctly reject function declarations without argument lists
+! note that there are no end statements for syntactically wrong function
+! declarations
+  interface
+     function f1     ! { dg-error "Expected formal argument list" }
+     function f3()
+     end function f3
+     function f4 result (x) ! { dg-error "Expected formal argument list" }
+     function f5() result (x)
+     end function f5
+   end interface
+  f1 = 1.
+end
+
+FUNCTION f1          ! { dg-error "Expected formal argument list" }
+
+function f2()
+  f2 = 1.
+end function f2
+
+function f3 result (x) ! { dg-error "Expected formal argument list" }
+
+function f4 () result (x)
+  x = 4.
+end function f4
index 2b457d9..6b91653 100644 (file)
@@ -3,7 +3,7 @@
 program testch
   if (ch().ne."hello     ") call abort()
 contains
-  function ch result(str)
+  function ch () result(str)
     character(len = 10)  :: str
     str ="hello"
   end function ch
index c91b270..f90a735 100644 (file)
@@ -6,7 +6,7 @@ program main
   if (.not. associated (x)) call abort
   if (size (x) .ne. 10) call abort
 contains
-  function test
+  function test()
     real, dimension (:), pointer :: test
     if (associated (x)) call abort
     allocate (test (10))