From patchwork Wed Sep 26 18:51:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 975356 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-486503-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="c4gj+Mv5"; 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 42L6VB2LtGz9s2P for ; Thu, 27 Sep 2018 04:51:28 +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:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=G3V8iVIxXHgM4UdxOagTNM08GsNHS7X+0ppGLaXMFdqSdrn58KzGF +Nj23hU7RmI/tI8b49cZ8JUfHOW94F1cvb+5B0o3vlt4SjtOKxxwC1Elm0H2lGzM mDKvbGI1Om33mYrwm229BIcGKMxyYFKpQrAwzhP49SGy6xFbqx6P3Y= 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:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=J3B3Lmodxq/2kfw/DQaoMJi4kZ4=; b=c4gj+Mv5BFaD5qPwcIPT 4wIwRohgrZzxPCifP5Ehzf7zmI3ootY9c12OU9BUZCzW8UnW0VDPAknpQi5ttiRT xehQyO4XoiaOZO73lPim7koAtFsL1aTC0OkHksZe8S8hW1nTmYEKT8a7TO+lGbrC PYrUUzbc6q1VlLmi3ZKYIRY= Received: (qmail 121488 invoked by alias); 26 Sep 2018 18:51:18 -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 121466 invoked by uid 89); 26 Sep 2018 18:51:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, 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=pedantic, H*r:0700 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Sep 2018 18:51:16 +0000 Received: from svr-orw-mbx-04.mgc.mentorg.com ([147.34.90.204]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1g5Eu2-0003nk-41 from Cesar_Philippidis@mentor.com ; Wed, 26 Sep 2018 11:51:14 -0700 Received: from [127.0.0.1] (147.34.91.1) by SVR-ORW-MBX-04.mgc.mentorg.com (147.34.90.204) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 26 Sep 2018 11:51:12 -0700 From: Cesar Philippidis Subject: [patch,wip] warn on noncontiguous pointers To: Fortran List , "gcc-patches@gcc.gnu.org" Message-ID: Date: Wed, 26 Sep 2018 11:51:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 As of GCC 8, gfortran now errors when a pointer with a contiguous attribute is set to point to a target without a contiguous attribute. I think this is overly strict, and should probably be demoted to a pedantic warning as I've done in the attached patch. I ran into this issue while I was tuning GCC for lsdalton. Specifically, CMake generates (not exactly because I reduced it) the following test case for ScaTeLib to determine if that library can be enabled: program test implicit none real,pointer :: fptr1(:) real,pointer,contiguous :: fptr3(:,:,:) allocate(fptr1(12)) call random_number(fptr1) !Test pointer reshape II fptr3(1:2,1:2,1:2) => fptr1(4:) end program Note how fptr1 doesn't have a contiguous attribute. Does anyone have thoughts on this? Maybe the ScaTeLib code needs to be updated. Thanks, Cesar Disable "Assignment to contiguous pointer from non-contiguous target" error 2018-XX-YY Cesar Philippidis gcc/fortran/ * expr.c (gfc_check_pointer_assign): Demote "Assignment to contiguous pointer from non-contiguous target" to a warning. --- diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 3315bb840af..74caa4f2d59 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3957,13 +3957,13 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) } } - /* Error for assignments of contiguous pointers to targets which is not + /* Warn for assignments of contiguous pointers to targets which is not contiguous. Be lenient in the definition of what counts as contiguous. */ if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true)) - gfc_error ("Assignment to contiguous pointer from non-contiguous " - "target at %L", &rvalue->where); + gfc_warning (OPT_Wpedantic, "Assignment to contiguous pointer from " + "non-contiguous target at %L", &rvalue->where); /* Warn if it is the LHS pointer may lives longer than the RHS target. */ if (warn_target_lifetime -- 2.17.1