re PR fortran/29806 (Error if CONTAINS is present without SUBPROGRAM)

fortran/
2006-11-15  Tobias Burnus  <burnus@net-b.de>

       PR fortran/29806
       * parse.c (parse_contained): Check for empty contains statement.

testsuite/
2006-11-15  Tobias Burnus  <burnus@net-b.de>

       PR fortran/29806
       * gfortran.dg/contains.f90: New test.
       * gfortran.dg/derived_function_interface_1.f90: Add a dg-warning.

From-SVN: r118851
This commit is contained in:
Tobias Burnus 2006-11-15 11:02:21 +01:00 committed by Tobias Burnus
parent 08700251e5
commit 8c894ae273
5 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2006-11-15 Tobias Burnus <burnus@net-b.de>
PR fortran/29806
* parse.c (parse_contained): Check for empty contains statement.
2006-11-15 Bud Davis <bdavis9659@sbcglobal.net>
PR fortran/28974

View File

@ -2757,6 +2757,7 @@ parse_contained (int module)
gfc_statement st;
gfc_symbol *sym;
gfc_entry_list *el;
int contains_statements = 0;
push_state (&s1, COMP_CONTAINS, NULL);
parent_ns = gfc_current_ns;
@ -2777,6 +2778,7 @@ parse_contained (int module)
case ST_FUNCTION:
case ST_SUBROUTINE:
contains_statements = 1;
accept_statement (st);
push_state (&s2,
@ -2860,6 +2862,11 @@ parse_contained (int module)
gfc_free_namespace (ns);
pop_state ();
if (!contains_statements)
/* This is valid in Fortran 2008. */
gfc_notify_std (GFC_STD_GNU, "Extension: "
"CONTAINS statement without FUNCTION "
"or SUBROUTINE statement at %C");
}

View File

@ -1,3 +1,9 @@
2006-11-15 Tobias Burnus <burnus@net-b.de>
PR fortran/29806
* gfortran.dg/contains.f90: New test.
* gfortran.dg/derived_function_interface_1.f90: Add a dg-warning.
2006-11-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/29581

View File

@ -0,0 +1,11 @@
! { dg-do compile }
! { dg-options "-std=f2003" }
! Check whether empty contains are allowd
! PR fortran/29806
module x
contains
end module x ! { dg-error "CONTAINS statement without FUNCTION or SUBROUTINE statement" }
program y
contains
end program y ! { dg-error "CONTAINS statement without FUNCTION or SUBROUTINE statement" }

View File

@ -37,4 +37,4 @@ contains
type(foo) function fun() ! { dg-error "already has an explicit interface" }
end function fun ! { dg-error "Expecting END PROGRAM" }
end
end ! { dg-warning "CONTAINS statement without FUNCTION or SUBROUTINE statement" }