From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26891 invoked by alias); 23 Aug 2017 17:33:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 26879 invoked by uid 89); 23 Aug 2017 17:33:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=argued X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Aug 2017 17:33:16 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D56BD61479; Wed, 23 Aug 2017 17:33:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D56BD61479 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dmalcolm@redhat.com Received: from c64.redhat.com (ovpn-112-20.phx2.redhat.com [10.3.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D37195F901; Wed, 23 Aug 2017 17:33:13 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org, Andreas Schwab Cc: David Malcolm Subject: [PATCH] C: fix logic within c_expr::get_location Date: Wed, 23 Aug 2017 19:35:00 -0000 Message-Id: <1503511727-32388-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg01391.txt.bz2 In r251239 I added a c_expr::get_location method for use by c_parser_expr_list for building the vec for an expression list, rather than using the location of the first token. When determining whether to use the location within the tree node, or fall back to the range in the c_expr, I used EXPR_CAN_HAVE_LOCATION, rather than EXPR_HAS_LOCATION. This meant that any tree nodes of kinds that *can* have a location but which erroneously had EXPR_LOCATION (value) == UNKNOWN_LOCATION had that value added to the vec, leading to missing location information when reporting on the issue (seen with gcc.dg/Wtraditional-conversion-2.c for m68k). This patch addresses this in two ways: (a) it fixes the specific issue in this failing test case, by setting up the location properly on the EXCESS_PRECISION_EXPR. (b) updating c_expr::get_location by only using the EXPR_LOCATION if it's sane. It could be argued that this could be papering over other "missing location" bugs, but if there are any, they are pre-existing ones exposed by r251239, and I'd rather have this fix in place than play whack-a-mole on any other such bugs that may be lurking in the codebase. Successfully bootstrapped®rtested on x86_64-pc-linux-gnu; I've verified the fix with --target=m68k-elf. OK for trunk? gcc/c/ChangeLog: * c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather than CAN_HAVE_LOCATION_P when determining whether to use the location_t value within "value". gcc/c-family/ChangeLog: * c-lex.c (interpret_float): Use token location when building an EXCESS_PRECISION_EXPR. --- gcc/c-family/c-lex.c | 2 +- gcc/c/c-tree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 3765a80..a614b26 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -988,7 +988,7 @@ interpret_float (const cpp_token *token, unsigned int flags, } if (type != const_type) - value = build1 (EXCESS_PRECISION_EXPR, type, value); + value = build1_loc (token->src_loc, EXCESS_PRECISION_EXPR, type, value); return value; } diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 5182cc5..96c7ae7 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -149,7 +149,7 @@ struct c_expr location_t get_location () const { - if (CAN_HAVE_LOCATION_P (value)) + if (EXPR_HAS_LOCATION (value)) return EXPR_LOCATION (value); else return make_location (get_start (), get_start (), get_finish ()); -- 1.8.5.3