From patchwork Mon Mar 24 11:29:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 333016 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 40CEE14008E for ; Mon, 24 Mar 2014 22:29:34 +1100 (EST) 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:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=JdVyMCEXIWq6HzFE rLAmA6zWil4yjcSQi/ptKrf7rEamb+1ZfY4nAu6dZPa9KjeLl9jzOq3xreSUF7VQ uSMDoI3vTCFUY7kZ9MwrZEHJEzn6tcIe3BenPiMcoAof/JNozrKluH5nyn+xfxzV mLSz3d5FnolLIYOsvqmubN5mAgo= 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:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=n+03ewDURozR/cetM3urGa Hpi4A=; b=T4wokoDADT0a4XRNF4TWAPW0Vj1IICOGbGsA3mAC1l7gyDZqmYFs5t d5FOSXtRyaMJyQdmcavACOVLVO8QBNxzHII2VOApFcjErh86FitKz5GrtfcIHA0Z Zx4GbjYbBl4J30XNmkVZFU2YgUW1bWbeDjeHjRGPLH2XKg0tDQ6dI= Received: (qmail 20021 invoked by alias); 24 Mar 2014 11:29:27 -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 19998 invoked by uid 89); 24 Mar 2014 11:29:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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; Mon, 24 Mar 2014 11:29:25 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2OBTNkG028835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Mar 2014 07:29:23 -0400 Received: from barimba (ovpn-113-169.phx2.redhat.com [10.3.113.169]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2OBTLdI021321 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 24 Mar 2014 07:29:22 -0400 From: Tom Tromey To: David Malcolm Cc: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [RFA jit] initialize input_location References: <1395327187-14524-1-git-send-email-tromey@redhat.com> <1395440318.10979.10.camel@surprise> Date: Mon, 24 Mar 2014 05:29:21 -0600 In-Reply-To: <1395440318.10979.10.camel@surprise> (David Malcolm's message of "Fri, 21 Mar 2014 18:18:38 -0400") Message-ID: <874n2nx2b2.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 >>>>> "Dave" == David Malcolm writes: Dave> Given this declaration in input.c: Dave> location_t input_location; Dave> then assigning 0 is a faithful way of resetting it to its initial state. Dave> That said, "0" feels like a magic number. Would it better to assign Dave> UNKNOWN_LOCATION to it? which is 0, c.f. input.h: Dave> #define UNKNOWN_LOCATION ((source_location) 0) Dave> If so, perhaps the declaration in input.c should gain an initializer to Dave> the same value? (shouldn't affect the code, since it's 0 either way, Dave> but perhaps it's more readable?) Sounds reasonable to me. How about the appended? Tom commit 79ce51eaf41ce7b0e90407245b7cad33ada6887b Author: Tom Tromey Date: Thu Mar 20 08:51:25 2014 -0600 initialize input_location This patch initializes input_location at the same spot where the line table is initialized. Without this, it's possible to crash when emitting a diagnostic in a reinvocation of the compiler, because input_location refers to a location that is no longer valid. diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit index ee1df88..5145cf9 100644 --- a/gcc/ChangeLog.jit +++ b/gcc/ChangeLog.jit @@ -1,3 +1,8 @@ +2014-03-24 Tom Tromey + + * toplev.c (general_init): Initialize input_location. + * input.c (input_location): Initialize to UNKNOWN_LOCATION. + 2014-03-19 Tom Tromey * timevar.h (auto_timevar): New class. diff --git a/gcc/input.c b/gcc/input.c index a141a92..90a708c 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -1,5 +1,5 @@ /* Data and functions related to line maps and input files. - Copyright (C) 2004-2013 Free Software Foundation, Inc. + Copyright (C) 2004-2014 Free Software Foundation, Inc. This file is part of GCC. @@ -25,7 +25,7 @@ along with GCC; see the file COPYING3. If not see /* Current position in real source file. */ -location_t input_location; +location_t input_location = UNKNOWN_LOCATION; struct line_maps *line_table; diff --git a/gcc/toplev.c b/gcc/toplev.c index b257ab2..54a884e 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1161,6 +1161,7 @@ general_init (const char *argv0) table. */ init_ggc (); init_stringpool (); + input_location = UNKNOWN_LOCATION; line_table = ggc_alloc_line_maps (); linemap_init (line_table); line_table->reallocator = realloc_for_line_map;