From patchwork Fri Nov 17 17:38:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 839078 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-467180-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YHAk6eRh"; 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 3ydlhw3tsZz9s0g for ; Sat, 18 Nov 2017 04:38:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=wLxMHKVEXjYQYYyUIEddWnHW36S92PPfa3qiLJOpt8qjEZPLZd Up3Vz0x3rIhe9bOlpnNywNrzDFE4woYk0mbqcbjiwVvlfiwlGzIUc/PYqOFVgTrI mQ0F3ekosLm85mpeZxHuK9c9glcHSmDuKw41nOYD38sU0ep2RS7YJxB10= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=rBjOmk41kolAykQJPE2BKVvhUBc=; b=YHAk6eRhWmB25LnAeRUB Klu2MtZT9eRf8LQqCKHkOJiaerJuPWKyHomPbBySU7cs0dtJOQeSCzwt+rOv5VX3 scbRdsHBMFLbxlpSRNR1646TwfNMj1iujxBH3090SxU/KtyT8v7UHLYLqE7NkfcD IHa26pRice/8Zyhr4oUUA1I= Received: (qmail 87620 invoked by alias); 17 Nov 2017 17:38:29 -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 87600 invoked by uid 89); 17 Nov 2017 17:38:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*tkoenig, HContent-Language:de-DE, H*r:sk:tkoenig, H*RU:sk:!192.16 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 17:38:26 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 89584127E8; Fri, 17 Nov 2017 18:38:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id 7D65011E00; Fri, 17 Nov 2017 18:38:22 +0100 (CET) Received: from [78.35.154.232] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 5a0f1e8e-02b8-7f0000012729-7f00000181a2-1 for ; Fri, 17 Nov 2017 18:38:22 +0100 Received: from [192.168.178.20] (xdsl-78-35-154-232.netcologne.de [78.35.154.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Fri, 17 Nov 2017 18:38:20 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 83012, rejects-valid regression with contiguous pointer Message-ID: Date: Fri, 17 Nov 2017 18:38:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Hello world, the attached patch fixes the PR by looking at the function interface if one exists. Regression-tested. OK for trunk? Regards Thomas 2017-11-17 Thomas Koenig PR fortran/83012 * expr.c (gfc_is_simply_contiguous): If a function call through a class variable is done through a reference, check the function's interface. 2017-11-17 Thomas Koenig PR fortran/83012 * gfortran.dg/contiguous_5.f90: New test. Index: expr.c =================================================================== --- expr.c (Revision 254408) +++ expr.c (Arbeitskopie) @@ -5185,8 +5185,31 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool str gfc_symbol *sym; if (expr->expr_type == EXPR_FUNCTION) - return expr->value.function.esym - ? expr->value.function.esym->result->attr.contiguous : false; + { + if (expr->value.function.esym) + 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) + return false; + + rc = NULL; + for (r = expr->ref; r; r = r->next) + if (r->type == REF_COMPONENT) + rc = r; + + if (rc == NULL || rc->u.c.component == NULL + || rc->u.c.component->ts.interface == NULL) + return false; + + return rc->u.c.component->ts.interface->attr.contiguous; + } + } else if (expr->expr_type != EXPR_VARIABLE) return false;