From 2b9a33aeea3d49f4e7038ecdc9d96b6220593d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= Date: Sat, 7 Jan 2006 17:30:53 +0100 Subject: [PATCH] decl.c (gfc_match_function_decl): Correctly error out in case of omitted function argument list. 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 --- gcc/fortran/ChangeLog | 5 ++++ gcc/fortran/decl.c | 7 ++++- gcc/testsuite/ChangeLog | 13 ++++++++++ gcc/testsuite/gfortran.dg/array_alloc_1.f90 | 2 +- gcc/testsuite/gfortran.dg/array_alloc_2.f90 | 2 +- gcc/testsuite/gfortran.dg/char_result_8.f90 | 4 +-- gcc/testsuite/gfortran.dg/dup_save_1.f90 | 8 +++--- gcc/testsuite/gfortran.dg/dup_save_2.f90 | 8 +++--- gcc/testsuite/gfortran.dg/f2c_6.f90 | 8 +++--- gcc/testsuite/gfortran.dg/f2c_7.f90 | 8 +++--- gcc/testsuite/gfortran.dg/func_decl_1.f90 | 26 +++++++++++++++++++ gcc/testsuite/gfortran.dg/func_result_2.f90 | 2 +- .../execute/pr23373-2.f90 | 2 +- 13 files changed, 72 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/func_decl_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ea086409fe8..112fc36dc9b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2005-01-07 Tobias Schl"uter + + * decl.c (gfc_match_function_decl): Correctly error out in case of + omitted function argument list. + 2006-01-07 Paul Thomas PR fortran/22146 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 1358cdcfb89..1d20a0d1eee 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a0e309a6b7..12d45c8f562 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2005-01-07 Tobias Schl"uter + + * 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 PR fortran/22146 diff --git a/gcc/testsuite/gfortran.dg/array_alloc_1.f90 b/gcc/testsuite/gfortran.dg/array_alloc_1.f90 index 86e69e0afd6..17be757a918 100644 --- a/gcc/testsuite/gfortran.dg/array_alloc_1.f90 +++ b/gcc/testsuite/gfortran.dg/array_alloc_1.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/array_alloc_2.f90 b/gcc/testsuite/gfortran.dg/array_alloc_2.f90 index 5381bf46e67..a225854f097 100644 --- a/gcc/testsuite/gfortran.dg/array_alloc_2.f90 +++ b/gcc/testsuite/gfortran.dg/array_alloc_2.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/char_result_8.f90 b/gcc/testsuite/gfortran.dg/char_result_8.f90 index b1dda89a600..4da9febe606 100644 --- a/gcc/testsuite/gfortran.dg/char_result_8.f90 +++ b/gcc/testsuite/gfortran.dg/char_result_8.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/dup_save_1.f90 b/gcc/testsuite/gfortran.dg/dup_save_1.f90 index d7ce8e127e6..7f22b62d167 100644 --- a/gcc/testsuite/gfortran.dg/dup_save_1.f90 +++ b/gcc/testsuite/gfortran.dg/dup_save_1.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/dup_save_2.f90 b/gcc/testsuite/gfortran.dg/dup_save_2.f90 index 1c0bfdbe554..3a24bdc9c5e 100644 --- a/gcc/testsuite/gfortran.dg/dup_save_2.f90 +++ b/gcc/testsuite/gfortran.dg/dup_save_2.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/f2c_6.f90 b/gcc/testsuite/gfortran.dg/f2c_6.f90 index b276b3df372..d28724cfa56 100644 --- a/gcc/testsuite/gfortran.dg/f2c_6.f90 +++ b/gcc/testsuite/gfortran.dg/f2c_6.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/f2c_7.f90 b/gcc/testsuite/gfortran.dg/f2c_7.f90 index c15ff7a0f2c..d67e10bc2c7 100644 --- a/gcc/testsuite/gfortran.dg/f2c_7.f90 +++ b/gcc/testsuite/gfortran.dg/f2c_7.f90 @@ -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 index 00000000000..c5576ef48de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/func_decl_1.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.dg/func_result_2.f90 b/gcc/testsuite/gfortran.dg/func_result_2.f90 index 2b457d9d44f..6b91653ed9d 100644 --- a/gcc/testsuite/gfortran.dg/func_result_2.f90 +++ b/gcc/testsuite/gfortran.dg/func_result_2.f90 @@ -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 diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/pr23373-2.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/pr23373-2.f90 index c91b270321e..f90a7357756 100644 --- a/gcc/testsuite/gfortran.fortran-torture/execute/pr23373-2.f90 +++ b/gcc/testsuite/gfortran.fortran-torture/execute/pr23373-2.f90 @@ -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))