From patchwork Sat Nov 19 21:04:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 83138 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp753527qge; Sat, 19 Nov 2016 13:05:11 -0800 (PST) X-Received: by 10.107.151.9 with SMTP id z9mr5970363iod.28.1479589511617; Sat, 19 Nov 2016 13:05:11 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g91si9397492ioi.199.2016.11.19.13.05.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Nov 2016 13:05:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442063-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-442063-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442063-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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; q=dns; s=default; b=QnFGPlfko5fIdPj9N hJUGbvR34dJt6Ju6pOB8oQGKF7FQWVW0Ae9G9cJHo9+X79wRwV9c+dAbIk4coeiC dehGeQTtANANrVrLWK0pYZWNY7vNR2ZphbYL37G5RIImmr9qHqhtdwuKx/rlIVjA zTVbhW0dY7QYx87dYK/2DO5rV0= 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; s=default; bh=WfvRCOhCkJuvjyddwhEFmIy f9eY=; b=rrOJpVOo3zZMDgY4zuwxVqMUGr8KXwvhlvn7ivzLibD2+iV46QbOG7z Zsfn0B9sKei3rfr889kg7XenMkofgL9XzdeUFzk7pE2wxaEfLK+NNCYg5qNIHG7V KSIkW0Bwb9+EuXKAzwXlDOMNRQIpb7EPvnq2bwP13b4OC3DrnpHc= Received: (qmail 40501 invoked by alias); 19 Nov 2016 21:04:56 -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 39874 invoked by uid 89); 19 Nov 2016 21:04:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=920, 6, 9206, pound, inconsistency X-HELO: mail-qk0-f194.google.com Received: from mail-qk0-f194.google.com (HELO mail-qk0-f194.google.com) (209.85.220.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Nov 2016 21:04:54 +0000 Received: by mail-qk0-f194.google.com with SMTP id x190so39415813qkb.0 for ; Sat, 19 Nov 2016 13:04:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=DsByaYItbXWuW+pwButaU4398/0VFF79c3KV5VswvlA=; b=TUFoXe7dpXFCb184huXRYM7UK8WG0AymC9vUPpIGS4PkgHrZ8rNWDesojpamVI+4kD GTUK0+Rq+3uKATkGAQxv15XlMimBwnDg3pBrq3h/N3csfp+K3ExyXN8zH2aSzp5dMMJQ kh58PnraWg5wuzSnOekcoyeo4tL4RU4junYlaJ+rNYiebxg46qbSDByDqL4BsO00F9Fq vpKYLSXmO6/CuSQy0tHuLQE83JU1EFc0I7EcNlzJy1r4X3Sfwr4AiRJ7VQ6Uk0dlpt2M S0V31vLCji8butGwjaY5+HVGs8ORv1TB244/4XKtdz627NVEJL35BHaT4ffd72BaWIpj o2HQ== X-Gm-Message-State: AKaTC01qPIqvSB0wHqJ0PBKLaoMFqHHjZXzeW7U7m0/9a18G6MO+VGF/uOwFHTU1Hw0NMw== X-Received: by 10.55.76.150 with SMTP id z144mr7068373qka.194.1479589492662; Sat, 19 Nov 2016 13:04:52 -0800 (PST) Received: from [192.168.0.26] (75-166-206-79.hlrn.qwest.net. [75.166.206.79]) by smtp.gmail.com with ESMTPSA id i19sm7274998qte.8.2016.11.19.13.04.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Nov 2016 13:04:52 -0800 (PST) Subject: Re: [RFC PATCH] avoid printing type suffix with %E (PR c/78165) To: Joseph Myers , Jeff Law References: <79de46b9-9770-02dd-6d98-9c72b7e6c59d@gmail.com> Cc: Gcc Patch List From: Martin Sebor Message-ID: <7dd11e5f-7a2d-7d2f-f34b-8b10f64029cc@gmail.com> Date: Sat, 19 Nov 2016 14:04:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes On 10/26/2016 02:46 PM, Joseph Myers wrote: > On Wed, 26 Oct 2016, Martin Sebor wrote: > >> The attached patch implements one such approach by having the pretty >> printer recognize the space format flag to suppress the type suffix, >> so "%E" still prints the suffix but "% E" does not. I did this to >> preserve the existing output but I think it would be nicer to avoid >> printing the suffix with %E and treat (for instance) the pound sign >> as a request to add the suffix. I have tested the attached patch >> but not the alternative. > > I think printing the suffixes is a relic of %E being used to print full > expressions. > > It's established by now that printing expressions reconstructed from trees > is a bad idea; we can get better results by having precise location ranges > and underlining the relevant part of the source. So if we could make sure > nowhere is trying the use %E (or %qE, etc.) with expressions that might > not be constants, where the type might be relevant, then we'd have > confidence that stopping printing the suffix is safe. But given the low > quality of the reconstructed expressions, it's probably safe anyway. > > (Most %qE uses are for identifiers not expressions. If we give > identifiers a different static type from "tree" - and certainly there > isn't much reason for them to have the same type as expressions - then > we'll need to change the format for either identifiers or expressions.) Attached is a trivial patch to remove the suffix. I didn't see any failures in the test suite as a result. I didn't attempt to remove the type suffix from any tests (nor did my relatively superficial search find any) but it will help simplify the tests for my patches that are still in the review queue. I should add to the rationale for the change I gave in my reply to Jeff: https://gcc.gnu.org/ml/gcc-patches/2016-11/msg01692.html that the print_dec[su] function that's sometimes used to format integers in warning messages (e.g., by the -Walloca-larger-than pass) doesn't add the suffix because it doesn't have knowledge of the argument's type (it operates on wide_int). That further adds to the inconsistency in diagnostics. This patch makes all integers in diagnostics consistent regardless of their type. Thanks Martin PR c/78165 - avoid printing type suffix for constants in %E output gcc/c-family/ChangeLog: PR c/78165 * c-pretty-print (pp_c_integer_constant): Avoid formatting type suffix. diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 7ad5900..c32d0a0 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -904,15 +904,6 @@ pp_c_void_constant (c_pretty_printer *pp) static void pp_c_integer_constant (c_pretty_printer *pp, tree i) { - int idx; - - /* We are going to compare the type of I to other types using - pointer comparison so we need to use its canonical type. */ - tree type = - TYPE_CANONICAL (TREE_TYPE (i)) - ? TYPE_CANONICAL (TREE_TYPE (i)) - : TREE_TYPE (i); - if (tree_fits_shwi_p (i)) pp_wide_integer (pp, tree_to_shwi (i)); else if (tree_fits_uhwi_p (i)) @@ -929,24 +920,6 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i) print_hex (wi, pp_buffer (pp)->digit_buffer); pp_string (pp, pp_buffer (pp)->digit_buffer); } - if (TYPE_UNSIGNED (type)) - pp_character (pp, 'u'); - if (type == long_integer_type_node || type == long_unsigned_type_node) - pp_character (pp, 'l'); - else if (type == long_long_integer_type_node - || type == long_long_unsigned_type_node) - pp_string (pp, "ll"); - else for (idx = 0; idx < NUM_INT_N_ENTS; idx ++) - if (int_n_enabled_p[idx]) - { - char buf[2+20]; - if (type == int_n_trees[idx].signed_type - || type == int_n_trees[idx].unsigned_type) - { - sprintf (buf, "I%d", int_n_data[idx].bitsize); - pp_string (pp, buf); - } - } } /* Print out a CHARACTER literal. */