From patchwork Wed Oct 23 22:09:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 285737 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 710A72C0097 for ; Thu, 24 Oct 2013 09:09:53 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=puHGnKccKNbByG84U4VM6J4+Fcd5XhXWQg4GJE4MK585Nz Ck77HmUoQuyLIcQ4/zNwnrW2pYmOxXP+MKBdD2ZXPHP2AwBBdBBmZ8nFBb5683aP PDG2xmLB//uN1EQQMuYRPGQv1B9UV0LF0vAGGByYcW+KvbaefeHmRmZG75VMY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=vNfUGcXENDRAjfg5yrJOXMw+uPs=; b=rIdrnRX787KZnma83uMI fVMznEn1mWjKmWSR0rGPUis6e/gMOUwKVS/CjSq5CYTCWOzymWYEuTa3zSjIkWEz 2xVvAHkg76qd33L0e19sgFurinULKHh5McAxipdSRHDK0xec2Kf/D2iLWgiuDAR0 EF3TU/4Zxzcb/VmH11srVsI= Received: (qmail 30976 invoked by alias); 23 Oct 2013 22:09:42 -0000 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 Received: (qmail 30949 invoked by uid 89); 23 Oct 2013 22:09:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 23 Oct 2013 22:09:39 +0000 Received: from archimedes.net-b.de (port-92-194-74-217.dynamic.qsc.de [92.194.74.217]) by mx02.qsc.de (Postfix) with ESMTP id C52C4278C7; Thu, 24 Oct 2013 00:09:35 +0200 (CEST) Message-ID: <5268491F.7080302@net-b.de> Date: Thu, 24 Oct 2013 00:09:35 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR44350 - add constraint check for BLOCK DATA A rather simple patch, which tries to implement Fortran 2008's C1116 (see also PR for the wording). While creating the patch, I found a reject-valid issue, which is now tracked as PR fortran/58857. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2013-10-23 Tobias Burnus PR fortran/44350 * parse.c (parse_spec): Add C1116 constraint check for BLOCK DATA. 2013-10-23 Tobias Burnus PR fortran/44350 * gfortran.dg/blockdata_8.f90: New. diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 512babf..e8b9885 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -2628,6 +2628,33 @@ loop: default: break; } + else if (gfc_current_state () == COMP_BLOCK_DATA) + /* Fortran 2008, C1116. */ + switch (st) + { + case ST_DATA_DECL: + case ST_COMMON: + case ST_DATA: + case ST_TYPE: + case ST_END_BLOCK_DATA: + case ST_ATTR_DECL: + case ST_EQUIVALENCE: + case ST_PARAMETER: + case ST_IMPLICIT: + case ST_IMPLICIT_NONE: + case ST_DERIVED_DECL: + case ST_USE: + break; + + case ST_NONE: + break; + + default: + gfc_error ("%s statement is not allowed inside of BLOCK DATA at %C", + gfc_ascii_statement (st)); + reject_statement (); + break; + } /* If we find a statement that can not be followed by an IMPLICIT statement (and thus we can expect to see none any further), type the function result diff --git a/gcc/testsuite/gfortran.dg/blockdata_8.f90 b/gcc/testsuite/gfortran.dg/blockdata_8.f90 new file mode 100644 index 0000000..d3f9925 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/blockdata_8.f90 @@ -0,0 +1,48 @@ +! { dg-do compile } +! +! PR fortran/44350 +! +! Fortran 2008, C1116 only permits a small subset of statements in BLOCK DATA +! +! Part of the test case was contributed by Vittorio Zecca +! +module m +end module m + +BLOCK DATA valid2 + use m + implicit integer(a-z) + intrinsic :: sin + common /one/ a, c + bind(C) :: /one/ + dimension c(5) + parameter (g = 7) +END BLOCK DATA valid2 + +BLOCK DATA valid + use m + implicit none + type t + sequence + end type t + type(t), save :: x + integer :: y + real :: q + save :: y + dimension :: q(5) +! class(*) :: zz ! See PR fortran/58857 +! pointer :: zz + target :: q + volatile y + asynchronous q +END BLOCK DATA valid + +block data invalid + common x + f(x)=x ! { dg-error "STATEMENT FUNCTION statement is not allowed inside of BLOCK DATA" } + interface ! { dg-error "INTERFACE statement is not allowed inside of BLOCK DATA" } + end interface +1 format() ! { dg-error "FORMAT statement is not allowed inside of BLOCK DATA" } +end block invalid ! { dg-error "Expecting END BLOCK DATA statement" } + +! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 }