Commit 9cc54940 by Arnaud Charlet Committed by Arnaud Charlet

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
parent 97d45cef
2010-06-01 Arnaud Charlet <charlet@adacore.com>
Matthew Gingell <gingell@adacore.com>
* 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.
2010-06-01 Richard Guenther <rguenther@suse.de>
PR lto/43853
......
......@@ -1133,7 +1133,7 @@ C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \
c-ppoutput.o c-cppbuiltin.o \
c-objc-common.o c-dump.o c-pch.o c-parser.o $(C_TARGET_OBJS) \
c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o
c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o c-ada-spec.o
# Language-specific object files for C.
C_OBJS = c-lang.o stub-objc.o $(C_AND_OBJC_OBJS)
......@@ -1995,7 +1995,7 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
opts.h $(C_PRAGMA_H) gt-c-decl.h $(CGRAPH_H) $(HASHTAB_H) libfuncs.h \
$(EXCEPT_H) $(LANGHOOKS_DEF_H) $(TREE_DUMP_H) $(C_COMMON_H) $(CPPLIB_H) \
$(DIAGNOSTIC_CORE_H) $(INPUT_H) langhooks.h tree-mudflap.h \
pointer-set.h tree-iterator.h c-lang.h $(PLUGIN_H)
pointer-set.h tree-iterator.h c-lang.h $(PLUGIN_H) c-ada-spec.h
c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(C_TREE_H) $(TARGET_H) $(FLAGS_H) intl.h output.h $(EXPR_H) \
$(TOPLEV_H) langhooks.h $(TREE_FLOW_H) tree-iterator.h c-lang.h
......@@ -2744,6 +2744,10 @@ tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
$(TREE_PASS_H) value-prof.h output.h tree-pretty-print.h
tree-diagnostic.o : tree-diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) $(DIAGNOSTIC_H) tree-diagnostic.h langhooks.h $(LANGHOOKS_DEF_H)
c-ada-spec.o : c-ada-spec.c c-ada-spec.h $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(REAL_H) $(HASHTAB_H) $(TREE_FLOW_H) \
$(CPP_ID_DATA_H) $(TM_H) coretypes.h tree-iterator.h tree-pass.h \
value-prof.h fixed-value.h output.h
fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(FLAGS_H) $(TOPLEV_H) $(HASHTAB_H) $(EXPR_H) $(RTL_H) \
$(GGC_H) $(TM_P_H) langhooks.h $(MD5_H) intl.h $(TARGET_H) \
......
/* Interface for -fdump-ada-spec capability.
Copyright (C) 2010, Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef C_ADA_SPEC_H
#define C_ADA_SPEC_H
#include "pretty-print.h"
/* In c-ada-spec.c */
typedef enum {
IS_ABSTRACT,
IS_CONSTRUCTOR,
IS_DESTRUCTOR,
IS_COPY_CONSTRUCTOR,
IS_TEMPLATE
} cpp_operation;
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 *),
int (*)(tree, cpp_operation));
#endif /* ! C_ADA_SPEC_H */
......@@ -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);
......
......@@ -435,10 +435,14 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
/* These tokens should not be visible outside cpplib. */
case CPP_HEADER_NAME:
case CPP_COMMENT:
case CPP_MACRO_ARG:
gcc_unreachable ();
/* CPP_COMMENT will appear when compiling with -C and should be
ignored. */
case CPP_COMMENT:
goto retry;
default:
*value = NULL_TREE;
break;
......
......@@ -164,7 +164,8 @@ in the following sections.
@gccoptlist{-c -S -E -o @var{file} -combine -no-canonical-prefixes @gol
-pipe -pass-exit-codes @gol
-x @var{language} -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help @gol
--version -wrapper@@@var{file} -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}}
--version -wrapper@@@var{file} -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} @gol
-fdump-ada-spec@r{[}-slim@r{]}}
@item C Language Options
@xref{C Dialect Options,,Options Controlling C Dialect}.
......@@ -987,7 +988,8 @@ Objective-C++ source code which should not be preprocessed.
@item @var{file}.h
C, C++, Objective-C or Objective-C++ header file to be turned into a
precompiled header.
precompiled header (default), or C, C++ header file to be turned into an
Ada spec (via the @option{-fdump-ada-spec} switch).
@item @var{file}.cc
@itemx @var{file}.cp
......@@ -1015,7 +1017,7 @@ Objective-C++ source code which should not be preprocessed.
@itemx @var{file}.HPP
@itemx @var{file}.h++
@itemx @var{file}.tcc
C++ header file to be turned into a precompiled header.
C++ header file to be turned into a precompiled header or Ada spec.
@item @var{file}.f
@itemx @var{file}.for
......@@ -1370,6 +1372,11 @@ Plugins API.
Define an argument called @var{key} with a value of @var{value}
for the plugin called @var{name}.
@item -fdump-ada-spec@r{[}-slim@r{]}
For C and C++ source and include files, generate corresponding Ada
specs. @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
GNAT User's Guide}, which provides detailed documentation on this feature.
@include @value{srcdir}/../libiberty/at-file.texi
@end table
......
......@@ -856,8 +856,7 @@ static const char *trad_capable_cpp =
therefore no dependency entry, confuses make into thinking a .o
file that happens to exist is up-to-date. */
static const char *cpp_unique_options =
"%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}}\
%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\
"%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\
%{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\
%{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\
%{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
......@@ -1091,12 +1090,12 @@ static const struct compiler default_compilers[] =
%(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
%(cc1_options)\
-o %g.s %{!o*:--output-pch=%i.gch}\
%W{o*:--output-pch=%*}%V}\
%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
%W{o*:--output-pch=%*}}%V}\
%{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
cc1 %(cpp_unique_options) %(cc1_options)\
-o %g.s %{!o*:--output-pch=%i.gch}\
%W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0},
%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
%W{o*:--output-pch=%*}}%V}}}}}}", 0, 0, 0},
{".i", "@cpp-output", 0, 1, 0},
{"@cpp-output",
"%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 1, 0},
......
......@@ -781,7 +781,8 @@ static struct dump_file_info dump_files[TDI_end] =
{".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
{".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
{".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
#define FIRST_AUTO_NUMBERED_DUMP 7
{".ads", "ada-spec", NULL, 0, 0, 7},
#define FIRST_AUTO_NUMBERED_DUMP 8
{NULL, "tree-all", NULL, TDF_TREE, 0, 0},
{NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
......
......@@ -38,6 +38,7 @@ enum tree_dump_index
TDI_nested, /* dump each function after unnesting it */
TDI_vcg, /* create a VCG graph file for each
function's flowgraph. */
TDI_ada, /* dump declarations in Ada syntax. */
TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
TDI_rtl_all, /* enable all the RTL dumps. */
TDI_ipa_all, /* enable all the IPA dumps. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment