]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gfc_match_function_decl): Correctly error out in case of omitted function...
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Sat, 7 Jan 2006 16:30:53 +0000 (17:30 +0100)
committerTobias Schlüter <tobi@gcc.gnu.org>
Sat, 7 Jan 2006 16:30:53 +0000 (17:30 +0100)
fortran/
* 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.

From-SVN: r109451

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 ea086409fe892fca30d0131d7d3cf365b5dabf6a..112fc36dc9b5ef870806d061835aa1aea26302f0 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 1358cdcfb892a8885581e4ee617f930c42e46d0a..1d20a0d1eeeeda1e8c677f90448fa50d48e7660f 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 7a0e309a6b7e30c3c70638f569c536c5ff8f2f3f..12d45c8f56218a6f4ef0e817c7182a0222661f4c 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 86e69e0afd68ad27b8ca33f9aac17a5fca56e752..17be757a918b5fbfe007dfa82380d6ad438040aa 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 5381bf46e678597935cb6784690746957d5052ce..a225854f097c939cac5c9578c0ab1315ee1c8c9d 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 b1dda89a600f082da23fc37b9a184e690121f121..4da9febe6066e2ee6578a5c2dab93ccbaf65d2ee 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 d7ce8e127e660114e53d00ed8d626e03737fe4a0..7f22b62d16749b8c6331f268ad6ba3e25f3820ab 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 1c0bfdbe554470ecee508a099623a4d43c456919..3a24bdc9c5ee2eec4b657df2ebba04a5cfaf8464 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 b276b3df3722b56353a7ee9bb6f9b614f8a37b4e..d28724cfa5670afc7a704f6b3a37d8000c3853fd 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 c15ff7a0f2c85ad207c2e61dcdbb10ed62c3d506..d67e10bc2c7c5629c633d0402500f7a09e7d5068 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 2b457d9d44f6a9b93e4f64859263e2dbd19957f2..6b91653ed9da878c317fa6158573076f72e50944 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 c91b270321ed0e814eafb379cec7ea5066b859a3..f90a7357756d385bf0f76060134dd010051374cf 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))