From patchwork Fri Dec 20 17:42:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1214244 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516384-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MEWLntyH"; 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 47fbfw0xF0z9sPW for ; Sat, 21 Dec 2019 04:42:30 +1100 (AEDT) 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=J3li82Gvpgw6WwoZ xMXE3vVR/+IlgFfhAHVo3Q6fJvRBBT2NDztPV4VqF2i1C6HB7DWW6N8pWfYhmpwY PNtxoc0QjLJwYfbuZaJ7jpC5NMYZbTdyDITZFnFI4AXPeQDYfKub7sxqDNBmFPkb 4spI1NZZ8qTenHK9TMYK2i5b2/g= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=60fGrUmqZWIlXEdXZRCPSp ErYeU=; b=MEWLntyHcAWYkg74BJSmJaIfKuVKWiW6vj3FQae/JsdY2XbJ9aYqZn qpgLioBTt2S5d+zPOX4c1YulRjyy6AJnl5zKkNIGjgDw4REhwE9fdATF+2afrthh 3CjhNikOQBepJS2EHpHpQq8bd+e2rw88juXB/IuDkQOIEe1ImWX/k= Received: (qmail 105599 invoked by alias); 20 Dec 2019 17:42:22 -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 102661 invoked by uid 89); 20 Dec 2019 17:42:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:c_parse, sloc, sk:DECL_SO, sk:decl_so X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2019 17:42:19 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id F3D40813A1 for ; Fri, 20 Dec 2019 18:42:16 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VEtYzKmfeTd9 for ; Fri, 20 Dec 2019 18:42:16 +0100 (CET) Received: from polaris.localnet (unknown [IPv6:2a01:e0a:41b:9230:1a03:73ff:fe45:373a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id CDDDB8137F for ; Fri, 20 Dec 2019 18:42:16 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix small glitch with -fdump-ada-spec Date: Fri, 20 Dec 2019 18:42:15 +0100 Message-ID: <2989632.ZzrmmeCWlY@polaris> MIME-Version: 1.0 This fixes the following discrepancy: when a C or C++ file contains no translation unit but only preprocessor macro definitions, -fdump-ada-spec outputs nothing but -fdump-ada-spec-slim does. This changes the former to behaving as the latter in this case. Tested on x86_64-suse-linux, applied on the mainline. 2019-12-20 Eric Botcazou c-family/ * c-ada-spec.h (decl_sloc): Delete. * c-ada-spec.c (decl_sloc): Make static. c/ * c-decl.c (collect_source_ref_cb): Delete. (for_each_global_decl): Rename into... (collect_source_refs): ...this. Call collect_source_ref directly. (c_parse_final_cleanups): Always call collect_source_ref on the main input filename. cp/ * decl2.c (c_parse_final_cleanups): Always call collect_source_ref on the main input filename. Index: c/c-decl.c =================================================================== --- c/c-decl.c (revision 279540) +++ c/c-decl.c (working copy) @@ -11787,15 +11787,6 @@ c_write_global_declarations_1 (tree glob while (reconsider); } -/* Callback to collect a source_ref from a DECL. */ - -static void -collect_source_ref_cb (tree decl) -{ - if (!DECL_IS_BUILTIN (decl)) - collect_source_ref (LOCATION_FILE (decl_sloc (decl, false))); -} - /* Preserve the external declarations scope across a garbage collect. */ static GTY(()) tree ext_block; @@ -11813,10 +11804,10 @@ collect_all_refs (const char *source_fil collect_ada_nodes (BLOCK_VARS (ext_block), source_file); } -/* Iterate over all global declarations and call CALLBACK. */ +/* Collect source file references at global level. */ static void -for_each_global_decl (void (*callback) (tree decl)) +collect_source_refs (void) { tree t; tree decls; @@ -11827,11 +11818,13 @@ for_each_global_decl (void (*callback) ( { decls = DECL_INITIAL (t); for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl)) - callback (decl); + if (!DECL_IS_BUILTIN (decl)) + collect_source_ref (DECL_SOURCE_FILE (decl)); } for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl)) - callback (decl); + if (!DECL_IS_BUILTIN (decl)) + collect_source_ref (DECL_SOURCE_FILE (decl)); } /* Perform any final parser cleanups and generate initial debugging @@ -11865,10 +11858,9 @@ c_parse_final_cleanups (void) if (flag_dump_ada_spec || flag_dump_ada_spec_slim) { /* Build a table of files to generate specs for */ - if (flag_dump_ada_spec_slim) - collect_source_ref (main_input_filename); - else - for_each_global_decl (collect_source_ref_cb); + collect_source_ref (main_input_filename); + if (!flag_dump_ada_spec_slim) + collect_source_refs (); dump_ada_specs (collect_all_refs, NULL); } Index: c-family/c-ada-spec.c =================================================================== --- c-family/c-ada-spec.c (revision 279540) +++ c-family/c-ada-spec.c (working copy) @@ -630,7 +630,7 @@ static const char *current_source_file; /* Return sloc of DECL, using sloc of last field if LAST is true. */ -location_t +static location_t decl_sloc (const_tree decl, bool last) { tree field; Index: c-family/c-ada-spec.h =================================================================== --- c-family/c-ada-spec.h (revision 279540) +++ c-family/c-ada-spec.h (working copy) @@ -36,7 +36,6 @@ enum cpp_operation { IS_TRIVIAL }; -extern location_t decl_sloc (const_tree, bool); extern void collect_ada_nodes (tree, const char *); extern void collect_source_ref (const char *); extern void dump_ada_specs (void (*)(const char *), Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 279540) +++ cp/decl2.c (working copy) @@ -4815,9 +4815,8 @@ c_parse_final_cleanups (void) /* Handle -fdump-ada-spec[-slim] */ if (flag_dump_ada_spec || flag_dump_ada_spec_slim) { - if (flag_dump_ada_spec_slim) - collect_source_ref (main_input_filename); - else + collect_source_ref (main_input_filename); + if (!flag_dump_ada_spec_slim) collect_source_refs (global_namespace); dump_ada_specs (collect_all_refs, cpp_check);