From patchwork Thu Aug 9 22:04:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cary Coutant X-Patchwork-Id: 176288 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]) by ozlabs.org (Postfix) with SMTP id 6DAA52C00C7 for ; Fri, 10 Aug 2012 08:05:04 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345154705; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=HAQ+kgL YzbPaXxaeifYTCAnPLRs=; b=QUp9mIk5ryob5MIPXet6b4Ww3FerYHSTC+9MlZj iAFCYBzsomKT9UbzlwiBdPgW3hRym7gz6AHoLruOxsEsQOe9ZnBAD4UiWn6cokLC +7gS4tq8MhMrBJZjzC0tNpQnk1hys9YPcWcbB1L3YDgveMbHrlR31BRbTjFNt1T3 F0K4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=vyeYfgN8sJVvHzPGF6KYQZO7fgxH/Qs5bMq2GIeAuYpG6RZCr8pwHBPwvNxJt5 l+dE2tMfY8b9sNMZx+LxdBlNNumQz3JlUgtbMDnmT4/4RarN8KdrKoZmTnZzqDS1 nXsdyzjja3E2PLwx3GpmKdpwE0ruclRkRWEXQuBZM9yYM=; Received: (qmail 21434 invoked by alias); 9 Aug 2012 22:05:01 -0000 Received: (qmail 21425 invoked by uid 22791); 9 Aug 2012 22:05:00 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ey0-f201.google.com (HELO mail-ey0-f201.google.com) (209.85.215.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Aug 2012 22:04:45 +0000 Received: by eabm6 with SMTP id m6so42773eab.2 for ; Thu, 09 Aug 2012 15:04:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=eiIOGR9n2HtAn2pELFJkSbOWEeo8vW0iW6q5Zxxgaqs=; b=lWVLHRyZV2wDeTG2ayO3By0zEwgZwhFRVtYIr91BxNnHioPyDgnlvtnJ2xoNxUXYhV A7ZybwPDBBHNWHE7qnQ2qjnQrHR8rLUh2NF6wcokfFI5l2JYTFco/M1ACmPHEzeMOWED KYPThzj+mEQ7CI99unlyrj+kktxGoXMAmBARfLite4KFM+itgese62uuqJYyhpghg834 96nKasQYLY0RPqZE4wcHb6odXDDGaLod9zoe86l6MsPnzaBVcMfk9kg/R3w2f04N42N9 uMjOGaf9NjLH0K8Wh/fb7ZId44SHzUwdBTLPKu3ygPMdUxb7S8VTSydGqQdbOTuDXOCQ 7rMQ== Received: by 10.14.182.7 with SMTP id n7mr906896eem.6.1344549884326; Thu, 09 Aug 2012 15:04:44 -0700 (PDT) Received: by 10.14.182.7 with SMTP id n7mr906885eem.6.1344549884259; Thu, 09 Aug 2012 15:04:44 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id d5si3085467eep.0.2012.08.09.15.04.44 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 09 Aug 2012 15:04:44 -0700 (PDT) Received: from ccoutant.mtv.corp.google.com (ccoutant.mtv.corp.google.com [172.18.110.42]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 14A7A5C0050; Thu, 9 Aug 2012 15:04:44 -0700 (PDT) Received: by ccoutant.mtv.corp.google.com (Postfix, from userid 62097) id 60C6DE0822; Thu, 9 Aug 2012 15:04:43 -0700 (PDT) To: aaw@google.com, gcc-patches@gcc.gnu.org Subject: [google/main, google/gcc-4_7] Fix segfault in linemap lookup Message-Id: <20120809220443.60C6DE0822@ccoutant.mtv.corp.google.com> Date: Thu, 9 Aug 2012 15:04:43 -0700 (PDT) From: ccoutant@google.com (Cary Coutant) X-Gm-Message-State: ALoCoQnxEhf9XuVv6hmiJvcu1ZjBhaXww9xCToqJZ+4QCPxS+F0ADzPsCd4QLOWw2bcWkbgOffoVb+QC4+yc74fozwNpXFtOe4wMyqk8hQkyovZ1jhGre+c50rrT57Ep9qtB+cvZvA/skz/zXtm74B6QhDN3yaMDWwrqv0g9Ymai2LTQAEEi2k/JLuNzCfh6HOm1SdZD+yvrBEItBDCTjL3AInT4//vARttERpx5X9JsV+aMM7CzM64= X-IsSubscribed: yes 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 This patch is for the google/main and google/gcc-4_7 branches. New code in GCC 4.7 is calling linemap_lookup with a location_t that may still represent a location-with-discriminator. Before using a location_t value to lookup the line number, it needs to be mapped to a real location_t value. Tested with make check-gcc and validate-failures.py. OK for google/main and google/gcc-4_7? 2012-08-09 Cary Coutant gcc/ * tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Check for discriminator. * diagnostic.c (diagnostic_report_current_module): Likewise. Index: gcc/tree-diagnostic.c =================================================================== --- gcc/tree-diagnostic.c (revision 190262) +++ gcc/tree-diagnostic.c (working copy) @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. #include "config.h" #include "system.h" #include "coretypes.h" +#include "input.h" #include "tree.h" #include "diagnostic.h" #include "tree-diagnostic.h" @@ -115,6 +116,8 @@ maybe_unwind_expanded_macro_loc (diagnos unsigned ix; loc_map_pair loc, *iter; + if (has_discriminator (where)) + where = map_discriminator_location (where); map = linemap_lookup (line_table, where); if (!linemap_macro_expansion_map_p (map)) return; Index: gcc/diagnostic.c =================================================================== --- gcc/diagnostic.c (revision 190262) +++ gcc/diagnostic.c (working copy) @@ -270,6 +270,9 @@ diagnostic_report_current_module (diagno if (where <= BUILTINS_LOCATION) return; + if (has_discriminator (where)) + where = map_discriminator_location (where); + linemap_resolve_location (line_table, where, LRK_MACRO_DEFINITION_LOCATION, &map);