From patchwork Fri Oct 11 08:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1175041 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-510723-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vogp0/Dv"; 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 46qMLj1BYnz9sP3 for ; Fri, 11 Oct 2019 19:58:35 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=rXaktzoUOTzV/QuB 1n/1oV3aPTBrsB/+bINVr7W4PKM3g35cnhNE2n87dQmg3tbeJh/GF7EbJbBA8L+C /DfZY6u+VUmJnPRY36+PyPnOHMWk+hXdlA8+nfEZdiRodTk7Pqt4ny74d1ZKK6sr WKuDuT9oUzrdIqhM/ZWaZdwWiO8= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=fP+bO5ZfJxwiz0/kUYnvlh eadiU=; b=vogp0/DvqURIwLFT96yrPJIUw5vRvEs8RY3RoJ70BBcEKqEgmu8VBm PT4A4kZf1koG6haqH7Jh5XTC3TJQ5TY1reQnONlFVAvtCwKWXvh0AbIDuFGULhFF 2EjfuSEONnu0uwSsIaYZ2SYbVI1XSvbzTfNHiHeVVoZt+tw2P5dMg= Received: (qmail 40495 invoked by alias); 11 Oct 2019 08:58:28 -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 40487 invoked by uid 89); 11 Oct 2019 08:58:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Really X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 08:58:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9E80E8139B for ; Fri, 11 Oct 2019 10:58:24 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xiBEiG7_rN2C for ; Fri, 11 Oct 2019 10:58:24 +0200 (CEST) Received: from polaris.localnet (unknown [IPv6:2a01:e35:8a16:3850:1a03:73ff:fe45:373a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 7ADF28139A for ; Fri, 11 Oct 2019 10:58:24 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix incorrect annotation for -gnatR Date: Fri, 11 Oct 2019 10:58:22 +0200 Message-ID: <3564997.pllQSurgsz@polaris> MIME-Version: 1.0 This fixes a thinko in an earlier match of mine for the annotation of integer constants in expressions: we really need to test the sign of the value when deciding to build a NEGATE_EXPR. Tested on x86_64-suse-linux, applied on all active branches. 2019-10-11 Eric Botcazou * gcc-interface/decl.c (annotate_value) : Really test the sign of the value when deciding to build a NEGATE_EXPR. : Remove redundant line. : Do the negation here. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 276865) +++ gcc-interface/decl.c (working copy) @@ -8287,9 +8287,8 @@ annotate_value (tree gnu_size) { case INTEGER_CST: /* For negative values, build NEGATE_EXPR of the opposite. Such values - can appear for discriminants in expressions for variants. Note that, - sizetype being unsigned, we don't directly use tree_int_cst_sgn. */ - if (tree_int_cst_sign_bit (gnu_size)) + can appear for discriminants in expressions for variants. */ + if (tree_int_cst_sgn (gnu_size) < 0) { tree t = wide_int_to_tree (sizetype, -wi::to_wide (gnu_size)); tcode = Negate_Expr; @@ -8367,9 +8366,8 @@ annotate_value (tree gnu_size) && tree_int_cst_sign_bit (TREE_OPERAND (gnu_size, 1))) { tcode = Minus_Expr; - ops[0] = annotate_value (TREE_OPERAND (gnu_size, 0)); - wide_int op1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); - ops[1] = annotate_value (wide_int_to_tree (sizetype, op1)); + wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); + ops[1] = annotate_value (wide_int_to_tree (sizetype, wop1)); break; } @@ -8410,9 +8408,9 @@ annotate_value (tree gnu_size) Such values can appear in expressions with aligning patterns. */ if (TREE_CODE (TREE_OPERAND (gnu_size, 1)) == INTEGER_CST) { - wide_int op1 = wi::sext (wi::to_wide (TREE_OPERAND (gnu_size, 1)), - TYPE_PRECISION (sizetype)); - ops[1] = annotate_value (wide_int_to_tree (sizetype, op1)); + wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); + tree op1 = wide_int_to_tree (sizetype, wop1); + ops[1] = annotate_value (build1 (NEGATE_EXPR, sizetype, op1)); } break;