From patchwork Tue Oct 1 23:46:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1170299 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-510026-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="lHKMGj2P"; 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 46jbX33Bhhz9s4Y for ; Wed, 2 Oct 2019 09:46:40 +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=iEAWXtrVaml3sadKaP/UVl5Dm+Yz4rHEYk/IBCz7icJ iPN5luTkHpsRiwu9RukBJbAUdk8Tfxc38H9ymU6ayCIO/m2I+qhukZiaSJXgalam e2FqJIA8HToCdwL4iAbzYB1Fx8IgCvCkY3k4iAuw/D07/Pj+ZNglShzrFDdMbbJU = 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=N8OlpujHky1f+W2BkNSTUqkcffA=; b=lHKMGj2P0YIBZ+NNz PQL5FDbm1vZabDO0zZ3FHnAdo+TUNMAi1A+kGwmC2qNbqbvHrW1adWPZ21htzbvp UvvRSWZNunlbNfpMn2cmiyVTxCtCMT5ZYG9Nc4bRS2b4O7GHkF8wK16xbu5xhgtN dA0aJxbsZsdreEa9siS0Dnp0ek= Received: (qmail 77903 invoked by alias); 1 Oct 2019 23:46:33 -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 77888 invoked by uid 89); 1 Oct 2019 23:46:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy= 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; Tue, 01 Oct 2019 23:46:32 +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 x91NkUlS090157 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 1 Oct 2019 16:46:30 -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 x91NkUhL090156; Tue, 1 Oct 2019 16:46:30 -0700 (PDT) (envelope-from sgk) Date: Tue, 1 Oct 2019 16:46:30 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/91784 -- Simplify EXPR_OP in conversion of constants Message-ID: <20191001234630.GA90127@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) The attached patch has been tested on x86_64-*-freebsd. OK to commmit? In a previous patch, I specialized the simplfication of an EXPR_OP to the case of an inserted parenthesis. This was too restrictive as evidenced by the new test case. The patch simply does a simplification of an expression. 2019-10-01 Steven G. Kargl PR fortran/91784 * simplify.c (gfc_convert_constant): Simplify expression if the expression type is EXPR_OP. 2019-10-01 Steven G. Kargl PR fortran/91784 * gfortran.dg/pr91784.f90: New test. Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (revision 276426) +++ gcc/fortran/simplify.c (working copy) @@ -8508,10 +8508,10 @@ 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) + else if (c->expr->expr_type == EXPR_OP) { - gfc_simplify_expr (c->expr, 1); + if (!gfc_simplify_expr (c->expr, 1)) + return &gfc_bad_expr; tmp = f (c->expr, kind); } else Index: gcc/testsuite/gfortran.dg/pr91784.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91784.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91784.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do run } +! PR fortran/91784 +! Code originally contributed by Gerhard Steinmetz +program p + complex :: x(1) + x = (1.0, 2.0) * [real :: -(3.0 + 4.0)] + if (int(real(x(1))) /= -7) stop 1 + if (int(aimag(x(1))) /= -14) stop 2 +end