From: Tobias Burnus Date: Wed, 15 Nov 2006 10:02:21 +0000 (+0100) Subject: re PR fortran/29806 (Error if CONTAINS is present without SUBPROGRAM) X-Git-Tag: releases/gcc-4.3.0~8456 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c894ae273073a4a45cd37be4ee2b06c35c40dd6;p=thirdparty%2Fgcc.git re PR fortran/29806 (Error if CONTAINS is present without SUBPROGRAM) fortran/ 2006-11-15 Tobias Burnus PR fortran/29806 * parse.c (parse_contained): Check for empty contains statement. testsuite/ 2006-11-15 Tobias Burnus PR fortran/29806 * gfortran.dg/contains.f90: New test. * gfortran.dg/derived_function_interface_1.f90: Add a dg-warning. From-SVN: r118851 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3206979dd591..44863998070d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2006-11-15 Tobias Burnus + + PR fortran/29806 + * parse.c (parse_contained): Check for empty contains statement. + 2006-11-15 Bud Davis PR fortran/28974 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 5aabbb48c87b..9d8551646667 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -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"); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a53e25c911e0..0288e558ba95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-11-15 Tobias Burnus + + 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 PR tree-optimization/29581 diff --git a/gcc/testsuite/gfortran.dg/contains.f90 b/gcc/testsuite/gfortran.dg/contains.f90 new file mode 100644 index 000000000000..221488afbe1b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contains.f90 @@ -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" } diff --git a/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 b/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 index 2cee73c3c02d..09916be63aed 100644 --- a/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 +++ b/gcc/testsuite/gfortran.dg/derived_function_interface_1.f90 @@ -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" }