From patchwork Fri Jun 25 18:20:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 56941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5038DB6F06 for ; Sat, 26 Jun 2010 04:20:40 +1000 (EST) Received: (qmail 2886 invoked by alias); 25 Jun 2010 18:20:21 -0000 Received: (qmail 2753 invoked by uid 22791); 25 Jun 2010 18:20:19 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_TM X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 18:20:13 +0000 Received: from [192.168.178.22] (port-92-204-98-222.dynamic.qsc.de [92.204.98.222]) by mx02.qsc.de (Postfix) with ESMTP id 0D8DA2196A; Fri, 25 Jun 2010 20:20:10 +0200 (CEST) Message-ID: <4C24F35A.4010606@net-b.de> Date: Fri, 25 Jun 2010 20:20:10 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4 Thunderbird/3.0.4 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, Fortran] F2008 allow END besides END SUBROUTINE/FUNCTION in contained procedures Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Another trivial F2008 change. The following Fortran 2003 constraint has been removed: C1243 (R1230) FUNCTION shall appear in the end-function-stmt of an internal or module function. (By the way, the "Introduction" of the F2008 standard lists the most important changes - such as this one.) Build and regtested on x86-64-linux. OK for the trunk? Tobias 2010-06-25 Tobias Burnus * decl.c (gfc_match_entry): Allow END besides END SUBROUTINE/END FUNCTION for contained procedures. 2010-06-25 Tobias Burnus * gfortran.dg/end_subroutine_1.f90: New. * gfortran.dg/end_subroutine_2.f90: New. * gfortran.dg/interface_proc_end.f90: Update. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (Revision 161388) +++ gcc/fortran/decl.c (Arbeitskopie) @@ -5642,7 +5646,14 @@ gfc_match_end (gfc_statement *st) if (gfc_match_eos () == MATCH_YES) { - if (!eos_ok) + if (!eos_ok && (*st == ST_END_SUBROUTINE || *st == ST_END_FUNCTION)) + { + if (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: END statement " + "instead of %s statement at %L", + gfc_ascii_statement (*st), &old_loc) == FAILURE) + goto cleanup; + } + else if (!eos_ok) { /* We would have required END [something]. */ gfc_error ("%s statement expected at %L", Index: gcc/testsuite/gfortran.dg/end_subroutine_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/end_subroutine_1.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/end_subroutine_1.f90 (Revision 0) @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! +interface + subroutine foo() + end + integer function bar() + end +end interface +contains + subroutine test() + end + integer function f() + f = 42 + end +end Index: gcc/testsuite/gfortran.dg/end_subroutine_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/end_subroutine_2.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/end_subroutine_2.f90 (Revision 0) @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +program main +interface + subroutine foo() + end + integer function bar() + end +end interface +contains + subroutine test() + end ! { dg-error "Fortran 2008: END statement instead of END SUBROUTINE" } + end subroutine ! To silence successive errors +end program + +subroutine test2() +contains + integer function f() + f = 42 + end ! { dg-error "Fortran 2008: END statement instead of END FUNCTION" } + end function ! To silence successive errors +end subroutine test2 + Index: gcc/testsuite/gfortran.dg/interface_proc_end.f90 =================================================================== --- gcc/testsuite/gfortran.dg/interface_proc_end.f90 (Revision 161388) +++ gcc/testsuite/gfortran.dg/interface_proc_end.f90 (Arbeitskopie) @@ -14,6 +14,5 @@ REAL :: TLS1,TLS2 END ! OK END INTERFACE - end ! { dg-error "END SUBROUTINE statement" } - end module ! { dg-error "END SUBROUTINE statement" } -! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 } + end subroutine + end module