From 36a549b86c6715edaa82a0408b71cff47f452a2f Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 1 Jun 2010 13:00:50 +0000 Subject: [PATCH] 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 From-SVN: r160103 --- gcc/cp/ChangeLog | 10 ++++++ gcc/cp/Make-lang.in | 4 +-- gcc/cp/decl2.c | 86 ++++++++++++++++++++++++++++++++++++++++++++- gcc/cp/lang-specs.h | 3 +- 4 files changed, 99 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 84b3bb447e7..b7d3e2d6b0e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2010-06-01 Arnaud Charlet + Matthew Gingell + + * 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. + 2010-05-29 Nathan Froyd * cp-tree.h (cp_build_function_call_nary): Declare. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 222988dff36..d726ead2d80 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -74,7 +74,7 @@ g++-cross$(exeext): g++$(exeext) CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \ c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \ incpath.o c-ppoutput.o c-cppbuiltin.o prefix.o \ - c-gimplify.o c-omp.o + c-gimplify.o c-omp.o c-ada-spec.o # Language-specific object files for C++ and Objective C++. CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \ @@ -260,7 +260,7 @@ cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h \ cp/decl2.o: cp/decl2.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h \ output.h $(EXCEPT_H) toplev.h $(C_COMMON_H) gt-cp-decl2.h $(CGRAPH_H) \ $(C_PRAGMA_H) $(TREE_DUMP_H) intl.h $(TARGET_H) $(GIMPLE_H) $(POINTER_SET_H) \ - $(SPLAY_TREE_H) + $(SPLAY_TREE_H) c-ada-spec.h cp/cp-objcp-common.o : cp/cp-objcp-common.c $(CONFIG_H) $(SYSTEM_H) \ coretypes.h $(TM_H) $(TREE_H) $(CXX_TREE_H) $(C_COMMON_H) toplev.h \ langhooks.h $(LANGHOOKS_DEF_H) $(DIAGNOSTIC_H) debug.h \ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0692e1a229f..33e0e265819 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. diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index 54d69a115fa..8aa3adf61a7 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -48,7 +48,8 @@ along with GCC; see the file COPYING3. If not see cc1plus %{save-temps|no-integrated-cpp:-fpreprocessed %{save-temps:%b.ii} %{!save-temps:%g.ii}}\ %{!save-temps:%{!no-integrated-cpp:%(cpp_unique_options)}}\ %(cc1_options) %2 %{+e1*}\ - %{!fsyntax-only:-o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}%V}}}}", + %{!fsyntax-only:%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}}%V}}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++", "%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}\