From patchwork Mon Aug 6 15:32:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 953970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483243-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ENvmcHZe"; dkim-atps=neutral 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 41khVK4p5gz9s3q for ; Tue, 7 Aug 2018 01:32:40 +1000 (AEST) Received: (qmail 26273 invoked by alias); 6 Aug 2018 15:32:33 -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 26248 invoked by uid 89); 6 Aug 2018 15:32:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=first, Having, H*F:D*acm.org, nathan X-HELO: mail-yw1-f46.google.com Received: from mail-yw1-f46.google.com (HELO mail-yw1-f46.google.com) (209.85.161.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Aug 2018 15:32:32 +0000 Received: by mail-yw1-f46.google.com with SMTP id q129-v6so3747769ywg.8 for ; Mon, 06 Aug 2018 08:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:cc:from:subject:message-id:date:user-agent:mime-version :content-language; bh=2OflxE20w2wC5aLB66fPtmTwVfaBqUfCw/ghCS/sw2Q=; b=ENvmcHZeUKScOGER6EuZO8hVKN3CzSHizyfUptoNxvpoaRX8ySsooYSA6tYthbjT8X fYuMYkTPXi+1rtINF3xz6Lecb3eaUuZ3izfPiRsGfwJQ+uFHg5+M8WrRYIon/HqXdNYq j/PrOisaBD4N2e0gdgcmSFpmHmY59BxgYIehtmAkNbUVAjHkjocgxIavYs6owhlVL8m6 Cku21OeacfLiNDvEdFnC8KdW6mQQF1fuNAAzLE1DcixMBaXpwBI53razIFCfJbuNvlkX nQt7MaERV+kcT3CmzbMhmTam6tUzVx2gq+EduhG1K51WQ8X6mTW7cMMBBwnTbAGNWBMp Vlww== Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::2:80bc]) by smtp.googlemail.com with ESMTPSA id x69-v6sm11164474ywx.105.2018.08.06.08.32.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 08:32:29 -0700 (PDT) Sender: Nathan Sidwell To: David Malcolm Cc: GCC Patches From: Nathan Sidwell Subject: [PATCH] Diagnostic included-from loop Message-ID: <1664468a-4474-5466-df05-dd4520fa08af@acm.org> Date: Mon, 6 Aug 2018 11:32:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 We currently emit the 'included from' information in a peeled-once loop. This patch rerolls the loop. It'll make some future changes simpler, and we're not at all worried about speed here -- it's a diagnostic! In the long term, the include-at path will include modules (imported at). Having single logic to figure that out is simpler. In the near future, I have a patch to change the representation of the included-from information, which I'll get to shortly. ok? nathan 2018-08-06 Nathan Sidwell * diagnostic.c (diagnostic_report_current_module): Reroll included-at loop. Index: diagnostic.c =================================================================== --- diagnostic.c (revision 263332) +++ diagnostic.c (working copy) @@ -587,22 +587,26 @@ diagnostic_report_current_module (diagno set_last_module (context, map); if (! MAIN_FILE_P (map)) { - map = INCLUDED_FROM (line_table, map); - const char *line_col - = maybe_line_and_column (LAST_SOURCE_LINE (map), - context->show_column - ? LAST_SOURCE_COLUMN (map) : 0); - pp_verbatim (context->printer, - "In file included from %r%s%s%R", "locus", - LINEMAP_FILE (map), line_col); - while (! MAIN_FILE_P (map)) + bool first = true; + do { map = INCLUDED_FROM (line_table, map); - line_col = maybe_line_and_column (LAST_SOURCE_LINE (map), 0); - pp_verbatim (context->printer, - ",\n from %r%s%s%R", "locus", - LINEMAP_FILE (map), line_col); + const char *line_col + = maybe_line_and_column (LAST_SOURCE_LINE (map), + first && context->show_column + ? SOURCE_COLUMN (map, where) : 0); + static const char *const msgs[] = + { + N_("In file included from"), + N_(" from"), + }; + unsigned index = !first; + pp_verbatim (context->printer, "%s%s %r%s%s%R", + first ? "" : ",\n", _(msgs[index]), + "locus", LINEMAP_FILE (map), line_col); + first = false; } + while (! MAIN_FILE_P (map)); pp_verbatim (context->printer, ":"); pp_newline (context->printer); }