Commit 8c894ae2 by Tobias Burnus Committed by Tobias Burnus

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
parent 08700251
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> 2006-11-15 Bud Davis <bdavis9659@sbcglobal.net>
PR fortran/28974 PR fortran/28974
......
...@@ -2757,6 +2757,7 @@ parse_contained (int module) ...@@ -2757,6 +2757,7 @@ parse_contained (int module)
gfc_statement st; gfc_statement st;
gfc_symbol *sym; gfc_symbol *sym;
gfc_entry_list *el; gfc_entry_list *el;
int contains_statements = 0;
push_state (&s1, COMP_CONTAINS, NULL); push_state (&s1, COMP_CONTAINS, NULL);
parent_ns = gfc_current_ns; parent_ns = gfc_current_ns;
...@@ -2777,6 +2778,7 @@ parse_contained (int module) ...@@ -2777,6 +2778,7 @@ parse_contained (int module)
case ST_FUNCTION: case ST_FUNCTION:
case ST_SUBROUTINE: case ST_SUBROUTINE:
contains_statements = 1;
accept_statement (st); accept_statement (st);
push_state (&s2, push_state (&s2,
...@@ -2860,6 +2862,11 @@ parse_contained (int module) ...@@ -2860,6 +2862,11 @@ parse_contained (int module)
gfc_free_namespace (ns); gfc_free_namespace (ns);
pop_state (); 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");
} }
......
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> 2006-11-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/29581 PR tree-optimization/29581
! { 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" }
...@@ -37,4 +37,4 @@ contains ...@@ -37,4 +37,4 @@ contains
type(foo) function fun() ! { dg-error "already has an explicit interface" } type(foo) function fun() ! { dg-error "already has an explicit interface" }
end function fun ! { dg-error "Expecting END PROGRAM" } end function fun ! { dg-error "Expecting END PROGRAM" }
end end ! { dg-warning "CONTAINS statement without FUNCTION or SUBROUTINE statement" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment