aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2010-06-01 12:57:57 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2010-06-01 14:57:57 +0200
commit9cc549409b6eaf87ba91362809738b0f1f3158e1 (patch)
treeec3e2b9e58ba96e229b86b77334b2495b9c3eff4 /gcc/c-decl.c
parent97d45cef597d472c47550365291dcdbf1c31ccec (diff)
downloadgcc-9cc549409b6eaf87ba91362809738b0f1f3158e1.zip
gcc-9cc549409b6eaf87ba91362809738b0f1f3158e1.tar.gz
gcc-9cc549409b6eaf87ba91362809738b0f1f3158e1.tar.bz2
invoke.texi: Mention -fdump-ada-spec.
* doc/invoke.texi: Mention -fdump-ada-spec. * tree-dump.c (dump_files): Add ada-spec. (FIRST_AUTO_NUMBERED_DUMP): Bump to 8. * tree-pass.h (tree_dump_index): Add TDI_ada. * gcc.c: Add support for -C without -E and for -fdump-ada-spec. (cpp_unique_options): Do not reject -C or -CC when -E isn't present. (default_compilers) <@c-header>: Allow -fdump-ada-spec on header files. * c-decl.c: Include c-ada-spec.h. (collect_source_ref_cb, collect_all_refs, for_each_global_decl): New functions. (c_write_global_declarations): Add handling of -fdump-ada-spec. * c-lex.c (c_lex_with_flags): Add handling of CPP_COMMENT. * Makefile.in (C_AND_OBJC_OBJS): Add c-ada-spec.o. * c-ada-spec.h, c-ada-spec.c: New files. Co-Authored-By: Matthew Gingell <gingell@adacore.com> From-SVN: r160100
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 82632d9..cda6ce3 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks-def.h"
#include "pointer-set.h"
#include "plugin.h"
+#include "c-ada-spec.h"
/* In grokdeclarator, distinguish syntactic contexts of declarators. */
enum decl_context
@@ -9614,6 +9615,43 @@ c_write_global_declarations_2 (tree globals)
debug_hooks->global_decl (decl);
}
+/* 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)));
+}
+
+/* Collect all references relevant to SOURCE_FILE. */
+
+static void
+collect_all_refs (const char *source_file)
+{
+ tree t;
+
+ for (t = all_translation_units; t; t = TREE_CHAIN (t))
+ collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
+}
+
+/* Iterate over all global declarations and call CALLBACK. */
+
+static void
+for_each_global_decl (void (*callback) (tree decl))
+{
+ tree t;
+ tree decls;
+ tree decl;
+
+ for (t = all_translation_units; t; t = TREE_CHAIN (t))
+ {
+ decls = DECL_INITIAL (t);
+ for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
+ callback (decl);
+ }
+}
+
/* Preserve the external declarations scope across a garbage collect. */
static GTY(()) tree ext_block;
@@ -9636,6 +9674,18 @@ c_write_global_declarations (void)
external_scope = 0;
gcc_assert (!current_scope);
+ /* Handle -fdump-ada-spec[-slim]. */
+ if (dump_enabled_p (TDI_ada))
+ {
+ /* Build a table of files to generate specs for */
+ if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
+ collect_source_ref (main_input_filename);
+ else
+ for_each_global_decl (collect_source_ref_cb);
+
+ dump_ada_specs (collect_all_refs, NULL);
+ }
+
if (ext_block)
{
tree tmp = BLOCK_VARS (ext_block);