From patchwork Wed Sep 11 18:41:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1161208 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-508883-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MQGLEPjJ"; 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 46T9j11jLQz9s7T for ; Thu, 12 Sep 2019 04:41: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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=Sv8llD7bs2sOpBmpZ+CdzcVxFH3zlMwYyAATK4MyEHB 79mBsBL7Ph6ebiaGApN6Vzj2uLlf75yINdUkGy6FMklv2U07w4UCYznyTaIl1uoL X4x05JkZf+KMHxFoQLLD/6GrT8aFhPzlrr7f5ybGs6Dz+AZaDs+avcsljKJbX3Ns = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=xR0cZLnG8/ZdHDDU85kEOyCbWiE=; b=MQGLEPjJkfUZ//Ns6 jLKAz4kz/dqOi0Ifx2WI7EVZW0nh1ibs5+Jgb9ctyhREFi36O0erQ2lI2XHSJybT 4NglNR94Gl77bVgCUv6QOitz2JF+kUPQo+wZg8+cLvFcKNZFm6aeLyPePinK5Bkz CwNeRhlFgj2XsxggqW368JThXw= Received: (qmail 102789 invoked by alias); 11 Sep 2019 18:41:11 -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 102776 invoked by uid 89); 11 Sep 2019 18:41:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1596 X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Sep 2019 18:41:10 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x8BIf8Dk010490 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 11 Sep 2019 11:41:08 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x8BIf8m6010489; Wed, 11 Sep 2019 11:41:08 -0700 (PDT) (envelope-from sgk) Date: Wed, 11 Sep 2019 11:41:03 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/91553 -- simplification of constants needs to check for parenthesis Message-ID: <20190911184103.GA10456@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Committed as obvious (once the problem is identified). When simplification of an expression occurs, parenthesis can be inserted. When simplifying a constant expression, need to check for inserted parenthesis. 2019-09-11 Steven G. Kargl PR fortran/91553 * simplify.c (gfc_convert_constant): During conversion check if the constant is enclosed in parenthesis, and simplify expression. 2019-09-11 Steven G. Kargl PR fortran/91553 * gfortran.dg/pr91553.f90: New test. Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (revision 275651) +++ gcc/fortran/simplify.c (working copy) @@ -8503,6 +8503,12 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind) { if (c->expr->expr_type == EXPR_ARRAY) tmp = gfc_convert_constant (c->expr, type, kind); + else if (c->expr->expr_type == EXPR_OP + && c->expr->value.op.op == INTRINSIC_PARENTHESES) + { + gfc_simplify_expr (c->expr, 1); + tmp = f (c->expr, kind); + } else tmp = f (c->expr, kind); } Index: gcc/testsuite/gfortran.dg/pr91553.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91553.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91553.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do run } +! Code contributed by Gerhard Steinmetz +program p + complex z(1) + z = (1.0, 2.0) * [real :: (3.0 + 4.0)] + if (real(z(1)) /= 7.) stop 1 + if (aimag(z(1)) /= 14.) stop 2 +end