From patchwork Thu Nov 11 22:47:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 70886 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 2C08AB7143 for ; Fri, 12 Nov 2010 09:48:07 +1100 (EST) Received: (qmail 14125 invoked by alias); 11 Nov 2010 22:48:01 -0000 Received: (qmail 14108 invoked by uid 22791); 11 Nov 2010 22:47:58 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Nov 2010 22:47:52 +0000 Received: from [192.168.178.22] (port-92-204-76-125.dynamic.qsc.de [92.204.76.125]) by mx01.qsc.de (Postfix) with ESMTP id 6CBE83D37D; Thu, 11 Nov 2010 23:47:50 +0100 (CET) Message-ID: <4CDC7295.9080402@net-b.de> Date: Thu, 11 Nov 2010 23:47:49 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.12) Gecko/20101026 SUSE/3.1.6 Thunderbird/3.1.6 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PRs 46413, 46205 - ICE with polymorphic I/O and nonscalar FORALL mask 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 The attached patches are rather trivial, fixing two ice-on-invalid PRs. Build and currently regtesting on x86-64-linux. OK for the trunk? Tobias 2010-11-11 Tobias Burnus PR fortran/46413 * resolve.c (resolve_transfer): Reject I/O transfer of polymorphic type. PR fortran/46205 * resolve.c (resolve_code): Reject nonscalar FORALL masks. 2010-11-11 Tobias Burnus PR fortran/46413 * gfortran.dg/class_31.f90: New. PR fortran/46205 * gfortran.dg/forall_14.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2c9d6f6..47562d9 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -7948,6 +7948,15 @@ resolve_transfer (gfc_code *code) if (ref->type == REF_COMPONENT) ts = &ref->u.c.component->ts; + if (ts->type == BT_CLASS) + { + /* FIXME: Test for defined input/output. */ + gfc_error ("Data transfer element at %L cannot be polymorphic unless " + "it is processed by a defined input/output procedure", + &code->loc); + return; + } + if (ts->type == BT_DERIVED) { /* Check that transferred derived type doesn't contain POINTER @@ -9098,8 +9107,9 @@ resolve_code (gfc_code *code, gfc_namespace *ns) case EXEC_FORALL: resolve_forall_iterators (code->ext.forall_iterator); - if (code->expr1 != NULL && code->expr1->ts.type != BT_LOGICAL) - gfc_error ("FORALL mask clause at %L requires a LOGICAL " + if (code->expr1 != NULL + && (code->expr1->ts.type != BT_LOGICAL || code->expr1->rank)) + gfc_error ("FORALL mask clause at %L requires a scalar LOGICAL " "expression", &code->expr1->where); break; diff --git a/gcc/testsuite/gfortran.dg/class_31.f90 b/gcc/testsuite/gfortran.dg/class_31.f90 new file mode 100644 index 0000000..eddf13f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_31.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! +! PR fortran/46413 +! +type t + integer :: ii =5 +end type t +class(t), allocatable :: x +allocate (t :: x) + +print *,x ! { dg-error "Data transfer element at .1. cannot be polymorphic" } +end diff --git a/gcc/testsuite/gfortran.dg/forall_14.f90 b/gcc/testsuite/gfortran.dg/forall_14.f90 new file mode 100644 index 0000000..16d47ca --- /dev/null +++ b/gcc/testsuite/gfortran.dg/forall_14.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! PR fortran/46205 +! +! Contributed by Jonathan Stott +! + +program forallBug + logical :: valid(4) = (/ .true., .true., .false., .true. /) + real :: vec(4) + integer :: j + + ! This is an illegal statement. It should read valid(j), not valid. + forall (j = 1:4, valid) ! { dg-error "requires a scalar LOGICAL expression" } + vec(j) = sin(2*3.14159/j) + end forall +end program forallBug