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
This commit is contained in:
Arnaud Charlet 2010-06-01 13:00:50 +00:00 committed by Arnaud Charlet
parent 0641fa9781
commit 36a549b86c
4 changed files with 99 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2010-06-01 Arnaud Charlet <charlet@adacore.com>
Matthew Gingell <gingell@adacore.com>
* 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 <froydnj@codesourcery.com>
* cp-tree.h (cp_build_function_call_nary): Declare.

View File

@ -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 \

View File

@ -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.

View File

@ -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)}\