From patchwork Sun Sep 9 20:34:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 967818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485375-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vxtw/fuG"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 427jbt2h6Rz9s4V for ; Mon, 10 Sep 2018 06:35:22 +1000 (AEST) 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=WbQxSHVS4IgtNXfW87g/DdszZ9N0BkztIgar0FaMvus1uW eMeCZ6mX0UV7XCYW4Al36xKl04Z+H1G5V/kNEYqDYPD9vCn+4njRn3lNabwYiq3D xl9JWdg6bsyUTKyPcOBS7u5Yq8xjhliVVWUi3ITCHliUEKv4qNNl7EStkgvNM= 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:from:date:message-id:subject:to:content-type; s= default; bh=Ap4TAu37Wd1efjtxzWM1myA5vlI=; b=vxtw/fuGIyMxJhK60YS4 /kaG0AB+lNi4eUDngieGxP82qOpvmu7NovQRqJ9N1KTZ8JKL0hm8I/T08BKPLxHg 58BH7ygAPTjZiOEmzh6ZQskhYxPFzaDwrhgSa7C8tK2zVPrQ2qQEAdOo+XhK+gaF Im/dL01FWRFCLJFQcD/4tXk= Received: (qmail 128015 invoked by alias); 9 Sep 2018 20:35:15 -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 127997 invoked by uid 89); 9 Sep 2018 20:35:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=D*gmx.de X-HELO: mail-yb1-f180.google.com Received: from mail-yb1-f180.google.com (HELO mail-yb1-f180.google.com) (209.85.219.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 09 Sep 2018 20:35:13 +0000 Received: by mail-yb1-f180.google.com with SMTP id t10-v6so7231084ybb.1; Sun, 09 Sep 2018 13:35:12 -0700 (PDT) MIME-Version: 1.0 From: Janus Weil Date: Sun, 9 Sep 2018 22:34:59 +0200 Message-ID: Subject: [Patch, Fortran] PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous To: gfortran , gcc-patches Hi all, the attached patch fixes a rejects-valid regression, where a type-bound procedure call was not correctly detected to have a contiguous result. The patch is functionally identical with comment #2 in the PR, with a little bit of cleanup on top of it. It regtests cleanly on x86_64-linux-gnu. Ok for trunk and gcc-8-branch? Cheers, Janus diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7cfb94ee115..7e2d6445237 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-09-09 Janus Weil + + PR fortran/86830 + * expr.c (gfc_is_simply_contiguous): Handle type-bound procedure calls + with non-polymorphic objects. + 2018-09-03 Jerry DeLisle * simplify.c (gfc_simplify_modulo): Re-arrange code to test whether diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index c5bf822cd24..97792fe32a7 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -5385,16 +5385,13 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool strict, bool permit_element) return expr->value.function.esym->result->attr.contiguous; else { - /* We have to jump through some hoops if this is a vtab entry. */ - gfc_symbol *s; - gfc_ref *r, *rc; - - s = expr->symtree->n.sym; - if (s->ts.type != BT_CLASS) + /* Type-bound procedures. */ + gfc_symbol *s = expr->symtree->n.sym; + if (s->ts.type != BT_CLASS && s->ts.type != BT_DERIVED) return false; - rc = NULL; - for (r = expr->ref; r; r = r->next) + gfc_ref *rc = NULL; + for (gfc_ref *r = expr->ref; r; r = r->next) if (r->type == REF_COMPONENT) rc = r; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c038441a8c..9e1ab44144f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-09 Janus Weil + + PR fortran/86830 + * gfortran.dg/typebound_call_30.f90: New test case. + 2018-09-08 Marek Polacek PR c++/87150 - wrong ctor with maybe-rvalue semantics. diff --git a/gcc/testsuite/gfortran.dg/typebound_call_30.f90 b/gcc/testsuite/gfortran.dg/typebound_call_30.f90 new file mode 100644 index 00000000000..3ca63bd2a95 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_30.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! +! PR 86830: [8/9 Regression] Contiguous array pointer function result not recognized as contiguous +! +! Contributed by + +module m + implicit none + + type :: t1 + contains + procedure :: get_ptr + end type + + type :: t2 + class(t1), allocatable :: c + end type + +contains + + function get_ptr(this) + class(t1) :: this + real, dimension(:), contiguous, pointer :: get_ptr + end function + + subroutine test() + real, dimension(:), contiguous, pointer:: ptr + type(t2) :: x + ptr => x%c%get_ptr() + end subroutine + +end module