From patchwork Tue Sep 18 09:37:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 971044 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-485867-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kjfyKxlA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LRw2mXih"; 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 42DybB6Zprz9sCD for ; Tue, 18 Sep 2018 19:37:57 +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:cc:content-type; q=dns; s=default; b=t3typOeThAtgxBNrjWFjZuYklZH8BnsFVPe9g4qLNgW PQpxy/N/LpkGlye+O7yc+Jm04xYrHeVbTohQ3exDEailfRSD5cun7ztqzYUQN79v NacdKlbh2B7lYWbzVhgCDV/Wd2YfrT+DHt9EIc9T9YgYdsIKW2jvLuB0A8INsw1E = 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:cc:content-type; s=default; bh=b3OKIzck1JCuMiXSQDP8F8Llq14=; b=kjfyKxlAxjR/LfHn8 5FZIfeDIBNXo0YTSl+ct3etfL8QPEiNUFS31A+vBQGt0Hcz1Nfl8nAdqqumMTEWK g/VbQO/SBL+uQP6c2uGNFV180CFcv7QSCmoTXT5V3zI2WlF+hJh520qGLihkYynb j/xgnLo55c7Bo6fUcdMxs7pqho= Received: (qmail 42671 invoked by alias); 18 Sep 2018 09:37:45 -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 42644 invoked by uid 89); 18 Sep 2018 09:37:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=se X-HELO: mail-yb1-f178.google.com Received: from mail-yb1-f178.google.com (HELO mail-yb1-f178.google.com) (209.85.219.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Sep 2018 09:37:43 +0000 Received: by mail-yb1-f178.google.com with SMTP id y20-v6so509940ybi.13; Tue, 18 Sep 2018 02:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=ZUW7weCbUSDpCnnsooDXlFjqmp01wnbxCLQVkZluWro=; b=LRw2mXih3IrhNj+yO8jeajW/h6Dv5MSlayhOn3ewyo5O2rAqyVfoQF9BnylipUNEqC 5sjCnmBtshV1KMKx6JYJh2ieOuwgSEhluUDK6JA6jUs81zzZLipG70XIGdMEFrOV8hBY +qEKEhhobi+44R0sWMracOOVexkOPM7By4lgDK9hAkR2BkNg67XTQX18hExBymOOaPDj W8q5+S9RKTK8CCJaaD89fjMCkXH6EFAPUiNivyP3cB1T/9fX9i1FeNmvOW0/Mut5s4Ln dpwC+7TYXE6iZtO2CxWMhDJxnYr1CwpzthR+22OpEhaSvclLuMgJ/3J1YuaraNFY5GX7 +B/A== MIME-Version: 1.0 Received: by 2002:a81:7a4b:0:0:0:0:0 with HTTP; Tue, 18 Sep 2018 02:37:40 -0700 (PDT) From: Paul Richard Thomas Date: Tue, 18 Sep 2018 10:37:40 +0100 Message-ID: Subject: [Patch, fortran] PR87336] [8/9 regression] wrong output for pointer dummy assiocated to target actual argument To: "fortran@gcc.gnu.org" , gcc-patches Cc: juergen.reuter@desy.de This one came up on clf yesterday. Thanks to Jeurgen Reuter for posting the PR. This is further fallout from the array descriptor changes. I decided not to pick out the special case involved but to set the 'span' field for all new (ie. 'parm') descriptors. A bit of fiddling around with gfc_get_array_span was needed to punt on incomplete types, unless a length could be found in the gfc_expr. Bootstraps and regtests on FC28/x86_64 - OK for 8- and 9-branches? Paul 2018-09-18 Paul Thomas PR fortran/87336 * trans-array.c (gfc_get_array_span): Try to get the element length of incomplete types. Return NULL_TREE otherwise. (gfc_conv_expr_descriptor): Only set the 'span' field if the above does not return NULL_TREE. Set 'span' field if possible for all new descriptors. 2018-09-18 Paul Thomas PR fortran/87336 * gfortran.dg/pointer_array_10.f90 : New test. * gfortran.dg/assign_10.f90 : Increase 'parm' count to 20. * gfortran.dg/transpose_optimization_2.f90 : Increase 'parm' count to 72. Index: gcc/fortran/trans-array.c =================================================================== *** gcc/fortran/trans-array.c (revision 264364) --- gcc/fortran/trans-array.c (working copy) *************** gfc_get_array_span (tree desc, gfc_expr *** 849,858 **** else { /* If none of the fancy stuff works, the span is the element ! size of the array. */ tmp = gfc_get_element_type (TREE_TYPE (desc)); ! tmp = fold_convert (gfc_array_index_type, ! size_in_bytes (tmp)); } return tmp; } --- 849,870 ---- else { /* If none of the fancy stuff works, the span is the element ! size of the array. Attempt to deal with unbounded character ! types if possible. Otherwise, return NULL_TREE. */ tmp = gfc_get_element_type (TREE_TYPE (desc)); ! if (tmp && TREE_CODE (tmp) == ARRAY_TYPE ! && TYPE_MAX_VALUE (TYPE_DOMAIN (tmp)) == NULL_TREE) ! { ! if (expr->expr_type == EXPR_VARIABLE ! && expr->ts.type == BT_CHARACTER) ! tmp = fold_convert (gfc_array_index_type, ! gfc_get_expr_charlen (expr)); ! else ! tmp = NULL_TREE; ! } ! else ! tmp = fold_convert (gfc_array_index_type, ! size_in_bytes (tmp)); } return tmp; } *************** gfc_conv_expr_descriptor (gfc_se *se, gf *** 7074,7080 **** /* ....and set the span field. */ tmp = gfc_get_array_span (desc, expr); ! gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp); } else if (se->want_pointer) { --- 7086,7093 ---- /* ....and set the span field. */ tmp = gfc_get_array_span (desc, expr); ! if (tmp != NULL_TREE) ! gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp); } else if (se->want_pointer) { *************** gfc_conv_expr_descriptor (gfc_se *se, gf *** 7344,7356 **** desc = info->descriptor; if (se->direct_byref && !se->byref_noassign) { ! /* For pointer assignments we fill in the destination.... */ parm = se->expr; parmtype = TREE_TYPE (parm); - - /* ....and set the span field. */ - tmp = gfc_get_array_span (desc, expr); - gfc_conv_descriptor_span_set (&loop.pre, parm, tmp); } else { --- 7357,7365 ---- desc = info->descriptor; if (se->direct_byref && !se->byref_noassign) { ! /* For pointer assignments we fill in the destination. */ parm = se->expr; parmtype = TREE_TYPE (parm); } else { *************** gfc_conv_expr_descriptor (gfc_se *se, gf *** 7388,7393 **** --- 7397,7407 ---- } } + /* Set the span field. */ + tmp = gfc_get_array_span (desc, expr); + if (tmp != NULL_TREE) + gfc_conv_descriptor_span_set (&loop.pre, parm, tmp); + offset = gfc_index_zero_node; /* The following can be somewhat confusing. We have two Index: gcc/testsuite/gfortran.dg/assign_10.f90 =================================================================== *** gcc/testsuite/gfortran.dg/assign_10.f90 (revision 264364) --- gcc/testsuite/gfortran.dg/assign_10.f90 (working copy) *************** end *** 23,27 **** ! cases will all yield a temporary, so that atmp appears 18 times. ! Note that it is the kind conversion that generates the temp. ! ! ! { dg-final { scan-tree-dump-times "parm" 18 "original" } } ! { dg-final { scan-tree-dump-times "atmp" 18 "original" } } --- 23,27 ---- ! cases will all yield a temporary, so that atmp appears 18 times. ! Note that it is the kind conversion that generates the temp. ! ! ! { dg-final { scan-tree-dump-times "parm" 20 "original" } } ! { dg-final { scan-tree-dump-times "atmp" 18 "original" } } Index: gcc/testsuite/gfortran.dg/pointer_array_10.f90 =================================================================== *** gcc/testsuite/gfortran.dg/pointer_array_10.f90 (nonexistent) --- gcc/testsuite/gfortran.dg/pointer_array_10.f90 (working copy) *************** *** 0 **** --- 1,27 ---- + ! { dg-do run } + ! + ! Test the fix for PR87336, in which the 'span' field of the array + ! descriptor, passed to 'show', was not set. + ! + ! Contributed by Juergen Reuter following + ! a posting to clf by 'Spectrum'. + ! + program main + implicit none + integer, target :: a( 2:4 ) + + a = [2,3,4] + ! print *, "a [before] = ", a + call show( a ) + ! print *, "a [after] = ", a + if (any (a .ne. [200,300,400])) stop 1 + + contains + subroutine show( arr ) + integer, pointer, intent(in) :: arr(:) + ! print *, "arr = ", arr + ! print *, "bounds = ", lbound(arr), ubound(arr) + arr(:) = [200,300,400] + ! print *, "arr2= ", arr + end subroutine show + end program Index: gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 =================================================================== *** gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 (revision 264364) --- gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 (working copy) *************** end *** 60,64 **** ! ! The check below for temporaries gave 14 and 33 for "parm" and "atmp". ! ! ! { dg-final { scan-tree-dump-times "parm" 66 "original" } } ! { dg-final { scan-tree-dump-times "atmp" 12 "original" } } --- 60,64 ---- ! ! The check below for temporaries gave 14 and 33 for "parm" and "atmp". ! ! ! { dg-final { scan-tree-dump-times "parm" 72 "original" } } ! { dg-final { scan-tree-dump-times "atmp" 12 "original" } }