From patchwork Thu Jan 26 23:52:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 138085 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 353781007D2 for ; Fri, 27 Jan 2012 10:52:38 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328226759; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=CbZaDx3 uozz+dHbmu59Y9P1YQfI=; b=aFcP0vHiOHuhYMQ4dpvyTCPWY5vmsNOJpwbpsME SZWG5JKXMCeXS9SHbqDWQ8ZXxcSbRVBCNN7aym0dUb+2H7iIiFyyG1czcLlUmSp/ zSHCiQJWGDBe+PYsOU033096Z4CzLiwHxAUKI4kmr4fUYhyK14qxsxRibohqOA7i Nz5Q= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=QGS0gqA3n5k1rEUhuNmB19eSSoYeT1bubVuClANtohwGVd0HoOW/WzxZxdn/IH a4vkFlRLiDCatYdw9rRSVUe9xWWCvsItTaVnI0tWZAXwHC0vzjRXzoPWgHQ3VDjM +mvpU9IIsIGLKMbHM7ZuEODroWRch4zpWIyc8tJjPsKi4=; Received: (qmail 21248 invoked by alias); 26 Jan 2012 23:52:35 -0000 Received: (qmail 21230 invoked by uid 22791); 26 Jan 2012 23:52:34 -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 mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Jan 2012 23:52:21 +0000 Received: from [192.168.178.22] (port-92-204-93-204.dynamic.qsc.de [92.204.93.204]) by mx02.qsc.de (Postfix) with ESMTP id F23941E4A0; Fri, 27 Jan 2012 00:52:18 +0100 (CET) Message-ID: <4F21E732.6070109@net-b.de> Date: Fri, 27 Jan 2012 00:52:18 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies 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 Dominique found out that there is no diagnostic for polymorphic arrays. This patch adds it. From the F2008 standard: "C1289 All dummy arguments of an elemental procedure shall be scalar noncoarray dummy data objects and shall not have the POINTER or ALLOCATABLE attribute." "An elemental subroutine has only scalar dummy arguments, but may have array actual arguments. In a reference to an elemental subroutine, either all actual arguments shall be scalar, or all actual arguments corresponding to INTENT (OUT) and INTENT (INOUT) dummy arguments shall be arrays of the same shape and the remaining actual arguments shall be conformable with them." Build and currently regtesting on x86-64-linux. OK for the trunk? Tobias 2012-01-27 Tobias Burnus * resolve.c (resolve_formal_arglist): Fix elemental constraint checks for polymorphic dummies. 2012-01-27 Tobias Burnus * gfortran.dg/elemental_args_check_5.f90: New. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (Revision 183575) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -374,21 +374,26 @@ resolve_formal_arglist (gfc_symbol *proc) if (gfc_elemental (proc)) { /* F08:C1289. */ - if (sym->attr.codimension) + if (sym->attr.codimension + || (sym->ts.type == BT_CLASS && CLASS_DATA (sym) + && CLASS_DATA (sym)->attr.codimension)) { gfc_error ("Coarray dummy argument '%s' at %L to elemental " "procedure", sym->name, &sym->declared_at); continue; } - if (sym->as != NULL) + if (sym->as || (sym->ts.type == BT_CLASS && CLASS_DATA (sym) + && CLASS_DATA (sym)->as)) { gfc_error ("Argument '%s' of elemental procedure at %L must " "be scalar", sym->name, &sym->declared_at); continue; } - if (sym->attr.allocatable) + if (sym->attr.allocatable + || (sym->ts.type == BT_CLASS && CLASS_DATA (sym) + && CLASS_DATA (sym)->attr.allocatable)) { gfc_error ("Argument '%s' of elemental procedure at %L cannot " "have the ALLOCATABLE attribute", sym->name, Index: gcc/testsuite/gfortran.dg/elemental_args_check_5.f90 =================================================================== --- gcc/testsuite/gfortran.dg/elemental_args_check_5.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/elemental_args_check_5.f90 (Arbeitskopie) @@ -0,0 +1,30 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! + type t + end type t + type t2 + end type t2 +contains +elemental subroutine foo0(v) ! OK + class(t), intent(in) :: v +end subroutine + +elemental subroutine foo1(w) ! { dg-error "Argument 'w' of elemental procedure at .1. cannot have the ALLOCATABLE attribute" } + class(t), allocatable, intent(in) :: w +end subroutine + +elemental subroutine foo2(x) ! { dg-error "Argument 'x' of elemental procedure at .1. cannot have the POINTER attribute" } + class(t), pointer, intent(in) :: x +end subroutine + +elemental subroutine foo3(y) ! { dg-error "Coarray dummy argument 'y' at .1. to elemental procedure" } + class(t2), intent(in) :: y[*] +end subroutine + +elemental subroutine foo4(z) ! { dg-error "Argument 'z' of elemental procedure at .1. must be scalar" } + class(t), intent(in) :: z(:) +end subroutine + +end