From patchwork Mon Nov 23 15:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1404873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@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.a=rsa-sha256 header.s=20161025 header.b=P52Vzaie; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CfrrN4s0Xz9sRK for ; Tue, 24 Nov 2020 02:37:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3398F384A030; Mon, 23 Nov 2020 15:37:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id 26F5B385481C for ; Mon, 23 Nov 2020 15:37:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 26F5B385481C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72d.google.com with SMTP id i199so3848729qke.5 for ; Mon, 23 Nov 2020 07:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=4UGOq2NB+ofPBzbHlSNsZRNcoJ/N8fL7d7s5Ay9vOtU=; b=P52Vzaieb1tThOjNJPC7onCqQXRphrhw9WBedtdobkcXLw+6lGJnKpkivjdWXw7QRj KZ3EXNbKl29+39bjlKHvg1xlMWi3EHeVo2E0ExRjh59/nfQhV1VHoywR50HjkaLnWw0E YFbc8+q4nHecCaAmfOBR5UDMU6EtBXlQ58TU/nJvY6YhrwjnaFBeod8xrE9xZO9Dy7L4 0/JKcwZmCOaEeti3DzrvCp4ZvouN0zAQtNu9aSvTd75mBs3nwefIlrT5eL5BjJgvvS/B /MSVBNIXrgf50YAT4o+mpsiH1B/BUvINOWj913gUeigRPE5baweEtzctkiolVQXIuKkg OixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=4UGOq2NB+ofPBzbHlSNsZRNcoJ/N8fL7d7s5Ay9vOtU=; b=QvzT6nah8GBXiSg2Jj6JB3h0Kg+h+msiqUuPgjMG1OoD3PAU4zx/Bik43zYxdo1iKy SCsOYEpVN5yV+Y9hLhdGBUzCgNzo926tRhAhI0Egp7uFlNLyuF+bGxJftX+o+Hf6wFkQ KDozhDLfKnrtNN5A/xQ+r397Btul3yVauSv320dVD5KLMVWvfDmjKssu5RodHI/AWXtZ 6SBXMl2kxlq1reP8PZGs79Fno6FNf2rqk7r1Xx051JP4XZlyOK8FJ18ks4dc4xhCgcjW W51BimX2Zs42rXGw3Rq7Fex5AL5G9ryRUV2HuuLsAj0NkdMVXbCCkqed3Y4DsApuHeMh cxAQ== X-Gm-Message-State: AOAM530oyalRYyyMwpXiyzjRMJnj3b2X6EM9i3UESjxdHjj4BBZbHuID Cqy7PcLXdCdD8meELGHgOTA= X-Google-Smtp-Source: ABdhPJx39ixTX1ybw7xQNAHJZMP4eJVcY9YcYKVE6dUZkVGs7huNTlQJxE61tvOeEhiw8AUTX5yMiA== X-Received: by 2002:a05:620a:1478:: with SMTP id j24mr2820336qkl.207.1606145853661; Mon, 23 Nov 2020 07:37:33 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:4c2:2316:c12a:3759? ([2620:10d:c091:480::1:bc23]) by smtp.googlemail.com with ESMTPSA id u21sm10488599qth.97.2020.11.23.07.37.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2020 07:37:32 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: Diagnostic for module importation Message-ID: <2f7344ae-4866-cb1a-4b4f-a96cc0986cdf@acm.org> Date: Mon, 23 Nov 2020 10:37:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This tweaks the 'included from ...' printing to deal with imports in the 'include' path. One new thing is that there can now be two 'include' names on a single line. For example 'in module X, included at Y'. This reads better than placing them on different lines. gcc/ * diagnostic.c (diagnostic_report_current_module): Adjust for C++ module importation. pushing to trunk diff --git i/gcc/diagnostic.c w/gcc/diagnostic.c index 1b6c9845892..fe509d88e6d 100644 --- i/gcc/diagnostic.c +++ w/gcc/diagnostic.c @@ -689,12 +689,13 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where) set_last_module (context, map); if (! MAIN_FILE_P (map)) { - bool first = true; + bool first = true, need_inc = true, was_module = MAP_MODULE_P (map); expanded_location s = {}; do { where = linemap_included_from (map); map = linemap_included_from_linemap (line_table, map); + bool is_module = MAP_MODULE_P (map); s.file = LINEMAP_FILE (map); s.line = SOURCE_LINE (map, where); int col = -1; @@ -706,14 +707,24 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where) const char *line_col = maybe_line_and_column (s.line, col); static const char *const msgs[] = { - N_("In file included from"), + NULL, N_(" from"), + N_("In file included from"), /* 2 */ + N_(" included from"), + N_("In module"), /* 4 */ + N_("of module"), + N_("In module imported at"), /* 6 */ + N_("imported at"), }; - unsigned index = !first; + + unsigned index = (was_module ? 6 : is_module ? 4 + : need_inc ? 2 : 0) + !first; + pp_verbatim (context->printer, "%s%s %r%s%s%R", - first ? "" : ",\n", _(msgs[index]), + first ? "" : was_module ? ", " : ",\n", + _(msgs[index]), "locus", s.file, line_col); - first = false; + first = false, need_inc = was_module, was_module = is_module; } while (! MAIN_FILE_P (map)); pp_verbatim (context->printer, ":");