From patchwork Sun Feb 3 16:20:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1035621 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-495199-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kuE3fL8G"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="g8fwJ0A5"; 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 43sx0S4rdSz9s4V for ; Mon, 4 Feb 2019 03:20:52 +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=so0jMw9hfnmRWhcb75PkQlptabrkVx12NCt3seqfWUL1WOj4GE vNGXX0aWWsKmWgT+3JsRvyBbNp9Bk0sp168UAw0Fph6CXZUFVdWCuX/xIyojf9hM Gqw45cnF8PCbMk8X9RKoDZayE03wD2XWY1mP/W4sDrxZoMMtEDy6ELAJ8= 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=KzmtwdbDpj0q5NiMrDOUD7YdBe0=; b=kuE3fL8GHF4Q1s+qtB4y TLLn9vjq59ZHdjfHXwjF7OyVBi/vtGEoXfJu1GOmJiBqfSCxMFM2HnsB8cYPXCiv epiXqIH+h+IWdDKTN/5IFOqmygjNyHB52Zixq6nC93X29VkmEzOWhQ7D4nIGppPg brUr4UoGlXeOzkWlAbdZBv8= Received: (qmail 23421 invoked by alias); 3 Feb 2019 16:20: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 23401 invoked by uid 89); 3 Feb 2019 16:20:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Feb 2019 16:20:42 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id C609013135; Sun, 3 Feb 2019 17:20:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1549210836; bh=a4Zzrqj13awXQ+O5funCvdZ7pa8FJCvek1oUZIjlqT8=; h=To:From:Subject:Message-ID:Date:From; b=g8fwJ0A5S1D5qXKKTxcCY9LKCCXwpe4pCxZvOov0m4MNLzZ8U0FAySi6SVlamXq/f IXVbttNN2Y5cYPKnoZ9tzWidmWlSvSVfUo57f6I3s0xC2pdeLuVztzt1XwTlA67l79 CZzwPdsvhOWGyCi/spbzFCJAAmPEzCW54JVsncE8f9/lAJQ49bgeqcy2tVN9eOIVJb yKZNf9/Eh9jExKTCROxrNTwZbxnPozVGsJTKMq94fgHHhRwoh8TN++BfsFG7aURUAU AtJ7GQBJXf3WqN38Hj9q93ylfWeQFt3SAOdv1GxPeDa8X1xxU13yGYxTJ7KzCtUBcD rViX62JZKCOEQ== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id B894F11D7B; Sun, 3 Feb 2019 17:20:36 +0100 (CET) Received: from [78.35.153.43] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c5714d4-0bea-7f0000012729-7f000001a616-1 for ; Sun, 03 Feb 2019 17:20:36 +0100 Received: from [192.168.178.68] (xdsl-78-35-153-43.nc.de [78.35.153.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 3 Feb 2019 17:20:35 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix part of PR 67679, spurious undefined warning Message-ID: <1401ee53-563d-a3eb-9f43-abfe393d365c@netcologne.de> Date: Sun, 3 Feb 2019 17:20:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Hello world, the attached patch fixes a 7/8/9 regression where a spurious warning about compiler-generated variables, with allocation on stat. The rest of the PR (ALLOCATE in an IF statememnt, later use of the array) is a dup of PR 66459, which has now been reclassified as a middle-end bug. If I get this part committed, I intend to resolve 67679 as a duplicate of 66459. Regression-tested. OK for trunk? Regards Thomas 2019-02-03 Thomas Koenig PR fortran/67679 * trans-array.c (gfc_array_allocate): For setting the bounds on the new array, add a condition for a not previously allocated variable. 2019-02-03 Thomas Koenig PR fortran/67679 * gfortran.dg/warn_undefined_1.f90: New test. * gfortran.dg/coarray_lock_7.f90: Fix patterns in test. Index: fortran/trans-array.c =================================================================== --- fortran/trans-array.c (Revision 268432) +++ fortran/trans-array.c (Arbeitskopie) @@ -5736,6 +5736,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree var_overflow = NULL_TREE; tree cond; tree set_descriptor; + tree not_prev_allocated = NULL_TREE; stmtblock_t set_descriptor_block; stmtblock_t elseblock; gfc_expr **lower; @@ -5881,8 +5882,6 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, } } - gfc_start_block (&elseblock); - /* Allocate memory to store the data. */ if (POINTER_TYPE_P (TREE_TYPE (se->expr))) se->expr = build_fold_indirect_ref_loc (input_location, se->expr); @@ -5898,6 +5897,19 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, pointer = gfc_conv_descriptor_data_get (se->expr); STRIP_NOPS (pointer); + if (allocatable) + { + not_prev_allocated = gfc_create_var (logical_type_node, + "not_prev_allocated"); + tmp = fold_build2_loc (input_location, EQ_EXPR, + logical_type_node, pointer, + build_int_cst (TREE_TYPE (pointer), 0)); + + gfc_add_modify (&se->pre, not_prev_allocated, tmp); + } + + gfc_start_block (&elseblock); + /* The allocatable variant takes the old pointer as first argument. */ if (allocatable) gfc_allocate_allocatable (&elseblock, pointer, size, token, @@ -5965,6 +5977,11 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, cond = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, status, build_int_cst (TREE_TYPE (status), 0)); + + if (not_prev_allocated != NULL_TREE) + cond = fold_build2_loc (input_location, TRUTH_OR_EXPR, + logical_type_node, cond, not_prev_allocated); + gfc_add_expr_to_block (&se->pre, fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, Index: testsuite/gfortran.dg/coarray_lock_7.f90 =================================================================== --- testsuite/gfortran.dg/coarray_lock_7.f90 (Revision 268432) +++ testsuite/gfortran.dg/coarray_lock_7.f90 (Arbeitskopie) @@ -35,8 +35,8 @@ end ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 0, 0, 0B, 0B, 0B, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 0, 0, 0B, 0B, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., .*\\(\\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., .*\\(\\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm...dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm...dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., .*\\(\\(3 - parm....dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm....dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm....dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm....dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., .*\\(\\(2 - parm....dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm....dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm....dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR \\+ 1\\) \\* \\(3 - parm....dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }