From patchwork Thu Mar 17 18:54:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 599216 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 3qQxkz09Knz9sBG for ; Fri, 18 Mar 2016 05:31:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=sxiEkNOV; 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:from :to:cc:subject:date:message-id; q=dns; s=default; b=YfPL9S1w5Snb nEDwIdy/fk3CGFH4ANQgpYLwYDHPQOaCF97kS9lHuvWLJPt+glMPHh5qoU4AeT70 l6MyEbDbJ4m042K4ataWEdyilZkd+YGgNgF+RBdCg1iAJk9iWqWAGFn3TILRkaEi qQerAjasGHFAoRBUbyMObXlF8F1ywcE= 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:cc:subject:date:message-id; s=default; bh=WTRTjpRVK5wmIeWpFy TOvLmamC8=; b=sxiEkNOV2dR7IIxQt8RyCqUCwyumGbLD8SfpyJwgbGGFVkGKbG uRSLQMFntYgrHl1iO2bNhfdy/Cp1YCmnq7VJpUP/Iq9IJd+wvc9R7qSW6hRrBd3Q t6aoNDbGkjSX3MiyzdI9Vi6lturDzzM5QHZBAo5eoOr1BPup95z3Jk9IQ= Received: (qmail 19498 invoked by alias); 17 Mar 2016 18:31:11 -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 19473 invoked by uid 89); 17 Mar 2016 18:31:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1853, sum 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 17 Mar 2016 18:31:07 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 43E97C05005E for ; Thu, 17 Mar 2016 18:31:06 +0000 (UTC) Received: from c64.redhat.com (vpn-229-167.phx2.redhat.com [10.3.229.167]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HIV5OR005899; Thu, 17 Mar 2016 14:31:05 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] PR c/70264: fix crash in compatible_locations_p with BUILTINS_LOCATION Date: Thu, 17 Mar 2016 14:54:14 -0400 Message-Id: <1458240854-37053-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes In r234088 my fix for PR c++/70105 didn't allow for the possibility that when comparing a pair of macro expansion histories that one of the macros in the history might not be located within a line-map, and PR c/70264 reports a crash due to encountering BUILTINS_LOCATION within the traversal. Fixed thusly. Successfully bootstrapped on x86_64-pc-linux-gnu; adds 4 PASS results to gcc.sum and 12 to g++.sum. Committed to trunk as r234303. gcc/ChangeLog: PR c/70264 * diagnostic-show-locus.c (compatible_locations_p): Handle the case where one or both locations aren't within a line_map. gcc/testsuite/ChangeLog: PR c/70264 * c-c++-common/pr70264.c: New test case. --- gcc/diagnostic-show-locus.c | 6 ++++++ gcc/testsuite/c-c++-common/pr70264.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/pr70264.c diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index 55ee6b6..6314675 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -490,6 +490,12 @@ compatible_locations_p (location_t loc_a, location_t loc_b) if (IS_ADHOC_LOC (loc_b)) loc_b = get_location_from_adhoc_loc (line_table, loc_b); + /* If either location is one of the special locations outside of a + linemap, they are only compatible if they are equal. */ + if (loc_a < RESERVED_LOCATION_COUNT + || loc_b < RESERVED_LOCATION_COUNT) + return loc_a == loc_b; + const line_map *map_a = linemap_lookup (line_table, loc_a); linemap_assert (map_a); diff --git a/gcc/testsuite/c-c++-common/pr70264.c b/gcc/testsuite/c-c++-common/pr70264.c new file mode 100644 index 0000000..815aad1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr70264.c @@ -0,0 +1,13 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +#define X __LINE__ /* { dg-error "expected" } */ +X + +/* { dg-begin-multiline-output "" } + #define X __LINE__ + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + X + ^ + { dg-end-multiline-output "" } */