From patchwork Mon Jan 23 19:45:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 718740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3v6hd66rzJz9t0q for ; Tue, 24 Jan 2017 06:45:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sp7DMfUO"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=k8KmTS04KYZWS4KJJq5dqu9qFxFVHacmCk8YGD7DE2vxQapciS6+h Db2odu5IqBcL0vDVm+PZStcTrSyztLDXCtKFM6YB6cvchJzaRAQKJK+A8J+e2Juc Awdk+RrQu2NUynFQO/GdRLA5y8bNC4G0XkbkQ2wNZmoUl66FJaAY7M= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=MksSxNJ3lEacvw3fxyplUxKrnoU=; b=sp7DMfUOjaE82BuZ6kHRtUpWV1ug 64lT39FGJxb/CXio2old2aFfAkw9/KOlhbi5lJbj7HILivgVJIFObqlj9Gr+snjt WQyPd0us1wSKUPEzLgMG3cNrWP+nM2FI3KVFnIvQsPaTqSx8v94TNIzf/EecgxoC HZnsUdF60MJhzHE= Received: (qmail 16640 invoked by alias); 23 Jan 2017 19:45:49 -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 16617 invoked by uid 89); 23 Jan 2017 19:45:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*fxcoudert, integer**, 8746, sk:opt_win X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Jan 2017 19:45:38 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id 68B7312991; Mon, 23 Jan 2017 20:45:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 6349711E19; Mon, 23 Jan 2017 20:45:36 +0100 (CET) Received: from [78.35.155.34] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 58865d60-0242-7f0000012729-7f00000184b8-1 for ; Mon, 23 Jan 2017 20:45:36 +0100 Received: from [192.168.178.20] (xdsl-78-35-155-34.netcologne.de [78.35.155.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Mon, 23 Jan 2017 20:45:34 +0100 (CET) Subject: Re: [patch, fortran] Warn about integer**(negative integer) To: FX References: <834FEB0D-ABA1-4FEC-872D-A75451040695@gmail.com> Cc: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Message-ID: Date: Mon, 23 Jan 2017 20:45:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <834FEB0D-ABA1-4FEC-872D-A75451040695@gmail.com> Hi FX, > The idea seems reasonable, but I am not sure about the wording > (“truncated” in particular). “Integer exponentiation truncated > to constant 0”? Why not “Negative integer exponent has result > value zero”? > > Other than that, OK to commit. You're right, the error message was a bit strange. Here is the version of the patch I committed with corresponding change in the test case. Regards Thomas else if (gfc_extract_int (op2, &power)) { Index: fortran/arith.c =================================================================== --- fortran/arith.c (Revision 244747) +++ fortran/arith.c (Arbeitskopie) @@ -874,6 +874,10 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_exp { /* if op2 < 0, op1**op2 == 0 because abs(op1) > 1. */ mpz_set_si (result->value.integer, 0); + if (warn_integer_division) + gfc_warning_now (OPT_Winteger_division, "Negative " + "exponent of integer has zero " + "result at %L", &result->where); }