diff options
author | Arnaud Charlet <charlet@adacore.com> | 2010-06-01 13:00:50 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-06-01 15:00:50 +0200 |
commit | 36a549b86c6715edaa82a0408b71cff47f452a2f (patch) | |
tree | 470146bbc9214ca527e017d227b62dd71f65fc97 /gcc/cp/decl2.c | |
parent | 0641fa9781e8cd257e0113360bef387bcbfd4b96 (diff) | |
download | gcc-36a549b86c6715edaa82a0408b71cff47f452a2f.zip gcc-36a549b86c6715edaa82a0408b71cff47f452a2f.tar.gz gcc-36a549b86c6715edaa82a0408b71cff47f452a2f.tar.bz2 |
Make-lang.in (CXX_C_OBJS): Add c-ada-spec.o.
* Make-lang.in (CXX_C_OBJS): Add c-ada-spec.o.
* decl2.c: Include langhooks.h and c-ada-spec.h.
(cpp_check, collect_source_refs, collect_ada_namespace,
collect_all_refs): New functions.
(cp_write_global_declarations): Add handling of -fdump-ada-spec.
* lang-specs.h: Ditto.
Co-Authored-By: Matthew Gingell <gingell@adacore.com>
From-SVN: r160103
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0692e1a..33e0e26 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1,6 +1,6 @@ /* Process declarations and variables for C++ compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Hacked by Michael Tiemann (tiemann@cygnus.com) @@ -52,6 +52,8 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "pointer-set.h" #include "splay-tree.h" +#include "langhooks.h" +#include "c-ada-spec.h" extern cpp_reader *parse_in; @@ -3461,6 +3463,69 @@ build_java_method_aliases (struct pointer_set_t *candidates) } } +/* Return C++ property of T, based on given operation OP. */ + +static int +cpp_check (tree t, cpp_operation op) +{ + switch (op) + { + case IS_ABSTRACT: + return DECL_PURE_VIRTUAL_P (t); + case IS_CONSTRUCTOR: + return DECL_CONSTRUCTOR_P (t); + case IS_DESTRUCTOR: + return DECL_DESTRUCTOR_P (t); + case IS_COPY_CONSTRUCTOR: + return DECL_COPY_CONSTRUCTOR_P (t); + case IS_TEMPLATE: + return TREE_CODE (t) == TEMPLATE_DECL; + default: + return 0; + } +} + +/* Collect source file references recursively, starting from NAMESPC. */ + +static void +collect_source_refs (tree namespc) +{ + tree t; + + if (!namespc) + return; + + /* Iterate over names in this name space. */ + for (t = NAMESPACE_LEVEL (namespc)->names; t; t = TREE_CHAIN (t)) + if (!DECL_IS_BUILTIN (t) ) + collect_source_ref (DECL_SOURCE_FILE (t)); + + /* Dump siblings, if any */ + collect_source_refs (TREE_CHAIN (namespc)); + + /* Dump children, if any */ + collect_source_refs (NAMESPACE_LEVEL (namespc)->namespaces); +} + +/* Collect decls relevant to SOURCE_FILE from all namespaces recursively, + starting from NAMESPC. */ + +static void +collect_ada_namespace (tree namespc, const char *source_file) +{ + if (!namespc) + return; + + /* Collect decls from this namespace */ + collect_ada_nodes (NAMESPACE_LEVEL (namespc)->names, source_file); + + /* Collect siblings, if any */ + collect_ada_namespace (TREE_CHAIN (namespc), source_file); + + /* Collect children, if any */ + collect_ada_namespace (NAMESPACE_LEVEL (namespc)->namespaces, source_file); +} + /* Returns true iff there is a definition available for variable or function DECL. */ @@ -3495,6 +3560,14 @@ no_linkage_error (tree decl) "is used but never defined", decl, t); } +/* Collect declarations from all namespaces relevant to SOURCE_FILE. */ + +static void +collect_all_refs (const char *source_file) +{ + collect_ada_namespace (global_namespace, source_file); +} + /* This routine is called at the end of compilation. Its job is to create all the code needed to initialize and destroy the global aggregates. We do the destruction @@ -3522,6 +3595,17 @@ cp_write_global_declarations (void) if (pch_file) c_common_write_pch (); + /* Handle -fdump-ada-spec[-slim] */ + if (dump_enabled_p (TDI_ada)) + { + if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM) + collect_source_ref (main_input_filename); + else + collect_source_refs (global_namespace); + + dump_ada_specs (collect_all_refs, cpp_check); + } + /* FIXME - huh? was input_line -= 1;*/ /* We now have to write out all the stuff we put off writing out. |