From patchwork Wed Dec 11 13:02:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 300054 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C4B222C007A for ; Thu, 12 Dec 2013 00:02:59 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=rKWYvyZrlydNb5nNsDqoVh+7v7oUfNkm0sVwOm9GFwiWsz 6Vrot7prZdr8kXBfnaN7TINJcpgOLEJmDAbwvwChwT0PjPWCI7M4ce3GZjrfG2l9 shiTBIYkceZYWbkKVN9MN99/XwSrucjiWptaiQjA4MLb/7pZWNjLku3bcLnFk= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=j9YRZwqgTu7IQwsPIkP5Qdy8fRA=; b=LgNYflJtYyr11QyYVC8c mE5WEhNJg8CFKG7oVUEwD04usr5MxRHghB6gGC5OgJVCyTCbxbaTXk7HAkWOi9it R+1pDA7StJtDuilOghkprxD9iaBZZXHnzjqdUbTwof5nptUonz2iWvZTMx6vU2w7 pUHnRSCk7x92n/RPWEhjOh4= Received: (qmail 21379 invoked by alias); 11 Dec 2013 13:02:53 -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 21358 invoked by uid 89); 11 Dec 2013 13:02:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-qc0-f177.google.com Received: from Unknown (HELO mail-qc0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Dec 2013 13:02:50 +0000 Received: by mail-qc0-f177.google.com with SMTP id m20so4907824qcx.8 for ; Wed, 11 Dec 2013 05:02:42 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.49.15.202 with SMTP id z10mr2435966qec.46.1386766961967; Wed, 11 Dec 2013 05:02:41 -0800 (PST) Received: by 10.96.156.38 with HTTP; Wed, 11 Dec 2013 05:02:41 -0800 (PST) Date: Wed, 11 Dec 2013 14:02:41 +0100 Message-ID: Subject: [Patch, Fortran, F03] PR 58916: Allocation of scalar with array source not rejected From: Janus Weil To: gfortran , gcc-patches Hi all, attached is a small patch which fixes accepts-invalid and ICE-on-invalid problems on allocation with source. Regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 2013-12-11 Janus Weil PR fortran/58916 * resolve.c (conformable_arrays): Treat scalar 'e2'. (resolve_allocate_expr): Check rank also for unlimited-polymorphic variables. 2013-12-11 Janus Weil PR fortran/58916 * gfortran.dg/allocate_with_source_4.f90: New. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 205872) +++ gcc/fortran/resolve.c (working copy) @@ -6597,7 +6597,8 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2) for (tail = e2->ref; tail && tail->next; tail = tail->next); /* First compare rank. */ - if (tail && e1->rank != tail->u.ar.as->rank) + if ((tail && e1->rank != tail->u.ar.as->rank) + || (!tail && e1->rank != e2->rank)) { gfc_error ("Source-expr at %L must be scalar or have the " "same rank as the allocate-object at %L", @@ -6794,8 +6795,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code } /* Check F03:C632 and restriction following Note 6.18. */ - if (code->expr3->rank > 0 && !unlimited - && !conformable_arrays (code->expr3, e)) + if (code->expr3->rank > 0 && !conformable_arrays (code->expr3, e)) goto failure; /* Check F03:C633. */