Commit f71f87f9 by Mark Mitchell Committed by Mark Mitchell

invoke.texi (-fdump-translation-unit): New option.

	* invoke.texi (-fdump-translation-unit): New option.
	* Make-lang.in (CXX_SRCS): Add dump.c.
	* Makefile.in (CXX_OBJS): Add dump.o.
	(dump.o): New target.
	* cp-tree.h (DECL_CONV_FN_P): Document.
	(DECL_OVERLOADED_OPERATOR_P): New function.
	(TYPE_PTRMEM_CLASS_TYPE): New macro.
	(TYPE_PTRMEM_POINTED_TO_TYPE): Likewise.
	(PTRMEM_CST_CLASS): Use TYPE_PTRMEM_CLASS_TYPE.
	(ASM_VOLATILE_P): New macro.
	(STMT_LINENO): Likewise.
	(cp_namespace_decls): New function.
	(dump_node_to_file): New function.
	* decl.c (cp_namespace_decls): New function.
	(walk_namespaces_r): Use it.
	(wrapup_globals_for_namespace): Likewise.
	* decl2.c (flag_dump_translation_unit): New variable.
	(lang_decode_option): Handle -fdump-translation-unit.
	(finish_file): If flag_dump_translation_unit is set, dump the
	translation unit.
	* dump.c: New file.
	* lang-options.h: Add -fdump-translation-unit.
	* pt.c (tsubst_template_parms): Robustify.
	(tsubst_decl): Use DECL_OVERLOADED_OPERATOR_P.
	(tsubst_expr): Use STMT_LINENO.
	* semantics.c (finish_asm_stmt): Eliminate duplicate code.  Check
	for invalid cv-qualifiers even while building templates.

From-SVN: r28434
parent 246833ac
Mon Aug 2 18:29:32 1999 Mark Mitchell <mark@codesourcery.com>
* invoke.texi (-fdump-translation-unit): New option.
Mon Aug 2 17:10:24 1999 Mark Mitchell <mark@codesourcery.com>
* toplev.h (errorcount): Declare.
......
1999-08-02 Mark Mitchell <mark@codesourcery.com>
* Make-lang.in (CXX_SRCS): Add dump.c.
* Makefile.in (CXX_OBJS): Add dump.o.
(dump.o): New target.
* cp-tree.h (DECL_CONV_FN_P): Document.
(DECL_OVERLOADED_OPERATOR_P): New function.
(TYPE_PTRMEM_CLASS_TYPE): New macro.
(TYPE_PTRMEM_POINTED_TO_TYPE): Likewise.
(PTRMEM_CST_CLASS): Use TYPE_PTRMEM_CLASS_TYPE.
(ASM_VOLATILE_P): New macro.
(STMT_LINENO): Likewise.
(cp_namespace_decls): New function.
(dump_node_to_file): New function.
* decl.c (cp_namespace_decls): New function.
(walk_namespaces_r): Use it.
(wrapup_globals_for_namespace): Likewise.
* decl2.c (flag_dump_translation_unit): New variable.
(lang_decode_option): Handle -fdump-translation-unit.
(finish_file): If flag_dump_translation_unit is set, dump the
translation unit.
* dump.c: New file.
* lang-options.h: Add -fdump-translation-unit.
* pt.c (tsubst_template_parms): Robustify.
(tsubst_decl): Use DECL_OVERLOADED_OPERATOR_P.
(tsubst_expr): Use STMT_LINENO.
* semantics.c (finish_asm_stmt): Eliminate duplicate code. Check
for invalid cv-qualifiers even while building templates.
1999-08-02 Richard Henderson <rth@cygnus.com>
* call.c: Include defaults.h instead of expr.h.
......
......@@ -117,7 +117,8 @@ CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
$(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
$(srcdir)/cp/error.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
$(srcdir)/cp/parse.y $(srcdir)/cp/sig.c $(srcdir)/cp/typeck2.c \
$(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c
$(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c \
$(srcdir)/cp/dump.c
cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o \
$(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def $(srcdir)/cp/gxx.gperf hash.o
......
......@@ -188,7 +188,7 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)
CXX_OBJS = call.o decl.o errfn.o expr.o pt.o sig.o typeck2.o \
class.o decl2.o error.o lex.o parse.o ptree.o rtti.o spew.o typeck.o cvt.o \
except.o friend.o init.o method.o search.o semantics.o tree.o xref.o \
repo.o @extra_cxx_objs@
repo.o dump.o @extra_cxx_objs@
# Language-independent object files.
OBJS = `cat ../stamp-objlist` ../c-common.o ../c-pragma.o
......@@ -306,7 +306,7 @@ repo.o : repo.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \
$(srcdir)/../toplev.h
semantics.o: semantics.c $(CONFIG_H) $(CXX_TREE_H) lex.h \
$(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h
dump.o: dump.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h
#
# These exist for maintenance purposes.
......
......@@ -315,7 +315,8 @@ struct tree_srcloc
#define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1(NODE)
/* Nonzero if this identifier is the prefix for a mangled C++ operator name. */
/* Nonzero if this identifier is the prefix for a mangled C++ operator
name. */
#define IDENTIFIER_OPNAME_P(NODE) TREE_LANG_FLAG_2(NODE)
/* Nonzero if this identifier is the name of a type-conversion
......@@ -1296,9 +1297,14 @@ struct lang_decl
(DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (NODE)) \
&& DECL_LANGUAGE (NODE) == lang_cplusplus)
/* Non-zero if NODE is a user-defined conversion operator. */
#define DECL_CONV_FN_P(NODE) \
(IDENTIFIER_TYPENAME_P (DECL_NAME (NODE)) && TREE_TYPE (DECL_NAME (NODE)))
/* Non-zero if NODE is an overloaded operator. */
#define DECL_OVERLOADED_OPERATOR_P(NODE) \
(IDENTIFIER_OPNAME_P (DECL_NAME ((NODE))))
/* For FUNCTION_DECLs: nonzero means that this function is a constructor
for an object with virtual baseclasses. */
#define DECL_CONSTRUCTOR_FOR_VBASE_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_for_vbase_attr)
......@@ -1857,12 +1863,22 @@ extern int flag_new_for_scope;
#define DELTA2_FROM_PTRMEMFUNC(NODE) delta2_from_ptrmemfunc ((NODE))
#define PFN_FROM_PTRMEMFUNC(NODE) pfn_from_ptrmemfunc ((NODE))
/* For a pointer-to-member type of the form `T X::*', this is `X'. */
#define TYPE_PTRMEM_CLASS_TYPE(NODE) \
(TYPE_PTRMEM_P ((NODE)) \
? TYPE_OFFSET_BASETYPE (TREE_TYPE ((NODE))) \
: TYPE_PTRMEMFUNC_OBJECT_TYPE ((NODE)))
/* For a pointer-to-member type of the form `T X::*', this is `T'. */
#define TYPE_PTRMEM_POINTED_TO_TYPE(NODE) \
(TYPE_PTRMEM_P ((NODE)) \
? TREE_TYPE (TREE_TYPE (NODE)) \
: TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE ((NODE))))
/* For a pointer-to-member constant `X::Y' this is the RECORD_TYPE for
`X'. */
#define PTRMEM_CST_CLASS(NODE) \
(TYPE_PTRMEM_P (TREE_TYPE (NODE)) \
? TYPE_OFFSET_BASETYPE (TREE_TYPE (TREE_TYPE (NODE))) \
: TYPE_PTRMEMFUNC_OBJECT_TYPE (TREE_TYPE (NODE)))
#define PTRMEM_CST_CLASS(NODE) \
TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (NODE))
/* For a pointer-to-member constant `X::Y' this is the _DECL for
`Y'. */
......@@ -2172,6 +2188,14 @@ extern int flag_new_for_scope;
#define ASM_INPUTS(NODE) TREE_OPERAND (NODE, 3)
#define ASM_CLOBBERS(NODE) TREE_OPERAND (NODE, 4)
/* Nonzero for an ASM_STMT if the assembly statement is volatile. */
#define ASM_VOLATILE_P(NODE) \
(ASM_CV_QUAL ((NODE)) != NULL_TREE)
/* The line-number at which a statement began. */
#define STMT_LINENO(NODE) \
(TREE_COMPLEXITY ((NODE)))
/* An enumeration of the kind of tags that C++ accepts. */
enum tag_types { record_type, class_type, union_type, enum_type,
signature_type };
......@@ -2990,6 +3014,7 @@ typedef int (*walk_namespaces_fn) PROTO((tree, void *));
extern int walk_namespaces PROTO((walk_namespaces_fn,
void *));
extern int wrapup_globals_for_namespace PROTO((tree, void *));
extern tree cp_namespace_decls PROTO((tree));
/* in decl2.c */
extern int check_java_method PROTO((tree));
......@@ -3604,6 +3629,9 @@ extern void GNU_xref_assign PROTO((tree));
extern void GNU_xref_hier PROTO((tree, tree, int, int, int));
extern void GNU_xref_member PROTO((tree, tree));
/* in dump.c */
extern void dump_node_to_file PROTO ((tree, char *));
/* -- end of C++ */
#endif /* not _CP_TREE_H */
......@@ -1808,6 +1808,15 @@ sigtable_decl_p (t, data)
&& IS_SIGNATURE (TREE_TYPE (t)));
}
/* Return the declarations that are members of the namespace NS. */
tree
cp_namespace_decls (ns)
tree ns;
{
return NAMESPACE_LEVEL (ns)->names;
}
/* Walk all the namespaces contained NAMESPACE, including NAMESPACE
itself, calling F for each. The DATA is passed to F as well. */
......@@ -1822,7 +1831,7 @@ walk_namespaces_r (namespace, f, data)
result |= (*f) (namespace, data);
for (current = NAMESPACE_LEVEL (namespace)->names;
for (current = cp_namespace_decls (namespace);
current;
current = TREE_CHAIN (current))
{
......@@ -1921,7 +1930,7 @@ wrapup_globals_for_namespace (namespace, data)
tree namespace;
void *data;
{
tree globals = NAMESPACE_LEVEL (namespace)->names;
tree globals = cp_namespace_decls (namespace);
int len = list_length (globals);
tree *vec = (tree *) alloca (sizeof (tree) * len);
int i;
......
......@@ -246,6 +246,11 @@ int flag_optional_diags = 1;
int flag_const_strings = 1;
/* If non-NULL, dump the tree structure for the entire translation
unit to this file. */
char *flag_dump_translation_unit = 0;
/* Nonzero means warn about deprecated conversion from string constant to
`char *'. */
......@@ -649,6 +654,13 @@ lang_decode_option (argc, argv)
name_mangling_version =
read_integral_parameter (p + 22, p - 2, name_mangling_version);
}
else if (!strncmp (p, "dump-translation-unit-", 22))
{
if (p[22] == '\0')
error ("no file specified with -fdump-translation-unit");
else
flag_dump_translation_unit = p + 22;
}
else for (j = 0;
!found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
j++)
......@@ -3721,6 +3733,11 @@ finish_file ()
finish_repo ();
/* The entire file is now complete. If requested, dump everything
file. */
if (flag_dump_translation_unit)
dump_node_to_file (global_namespace, flag_dump_translation_unit);
this_time = get_run_time ();
parse_time -= this_time - start_time;
varconst_time += this_time - start_time;
......
This diff is collapsed. Click to expand it.
......@@ -38,6 +38,7 @@ DEFINE_LANG_NAME ("C++")
{ "-fconst-strings", "" },
{ "-fno-const-strings", "Make string literals `char[]' instead of `const char[]'" },
{ "-fdefault-inline", "" },
{ "-fdump-translation-unit-", "Dump the entire translation unit to a file"},
{ "-fno-default-inline", "Do not inline member functions by default"},
{ "-frtti", "" },
{ "-fno-rtti", "Do not generate run time type descriptor information" },
......
......@@ -5307,8 +5307,8 @@ tsubst_template_parms (parms, args, complain)
tree args;
int complain;
{
tree r;
tree* new_parms = &r;
tree r = NULL_TREE;
tree* new_parms;
for (new_parms = &r;
TMPL_PARMS_DEPTH (parms) > TMPL_ARGS_DEPTH (args);
......@@ -5822,7 +5822,7 @@ tsubst_decl (t, args, type, in_decl)
maybe_retrofit_in_chrg (r);
grok_ctor_properties (ctx, r);
}
if (IDENTIFIER_OPNAME_P (DECL_NAME (r)))
else if (DECL_OVERLOADED_OPERATOR_P (r))
grok_op_properties (r, DECL_VIRTUAL_P (r), DECL_FRIEND_P (r));
}
break;
......@@ -7077,13 +7077,13 @@ tsubst_expr (t, args, complain, in_decl)
switch (TREE_CODE (t))
{
case RETURN_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
finish_return_stmt (tsubst_expr (RETURN_EXPR (t),
args, complain, in_decl));
break;
case EXPR_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
finish_expr_stmt (tsubst_expr (EXPR_STMT_EXPR (t),
args, complain, in_decl));
break;
......@@ -7093,7 +7093,7 @@ tsubst_expr (t, args, complain, in_decl)
int i = suspend_momentary ();
tree dcl, init;
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
emit_line_note (input_filename, lineno);
dcl = start_decl
(tsubst (TREE_OPERAND (t, 0), args, complain, in_decl),
......@@ -7109,7 +7109,7 @@ tsubst_expr (t, args, complain, in_decl)
case FOR_STMT:
{
tree tmp;
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_for_stmt ();
for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp))
......@@ -7127,7 +7127,7 @@ tsubst_expr (t, args, complain, in_decl)
case WHILE_STMT:
{
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_while_stmt ();
finish_while_stmt_cond (tsubst_expr (WHILE_COND (t),
args, complain, in_decl),
......@@ -7139,7 +7139,7 @@ tsubst_expr (t, args, complain, in_decl)
case DO_STMT:
{
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_do_stmt ();
tsubst_expr (DO_BODY (t), args, complain, in_decl);
finish_do_body (NULL_TREE);
......@@ -7153,7 +7153,7 @@ tsubst_expr (t, args, complain, in_decl)
{
tree tmp;
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_if_stmt ();
finish_if_stmt_cond (tsubst_expr (IF_COND (t),
args, complain, in_decl),
......@@ -7180,7 +7180,7 @@ tsubst_expr (t, args, complain, in_decl)
{
tree substmt;
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
for (substmt = COMPOUND_BODY (t);
substmt != NULL_TREE;
......@@ -7192,12 +7192,12 @@ tsubst_expr (t, args, complain, in_decl)
break;
case BREAK_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
finish_break_stmt ();
break;
case CONTINUE_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
finish_continue_stmt ();
break;
......@@ -7205,7 +7205,7 @@ tsubst_expr (t, args, complain, in_decl)
{
tree val, tmp;
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_switch_stmt ();
val = tsubst_expr (SWITCH_COND (t), args, complain, in_decl);
finish_switch_cond (val);
......@@ -7230,7 +7230,7 @@ tsubst_expr (t, args, complain, in_decl)
break;
case GOTO_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
t = GOTO_DESTINATION (t);
if (TREE_CODE (t) != IDENTIFIER_NODE)
/* Computed goto's must be tsubst'd into. On the other hand,
......@@ -7241,7 +7241,7 @@ tsubst_expr (t, args, complain, in_decl)
break;
case ASM_STMT:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
finish_asm_stmt (ASM_CV_QUAL (t),
tsubst_expr (ASM_STRING (t), args, complain, in_decl),
tsubst_expr (ASM_OUTPUTS (t), args, complain, in_decl),
......@@ -7251,7 +7251,7 @@ tsubst_expr (t, args, complain, in_decl)
break;
case TRY_BLOCK:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
finish_try_block (NULL_TREE);
......@@ -7264,7 +7264,7 @@ tsubst_expr (t, args, complain, in_decl)
break;
case HANDLER:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
begin_handler ();
if (HANDLER_PARMS (t))
{
......@@ -7281,7 +7281,7 @@ tsubst_expr (t, args, complain, in_decl)
break;
case TAG_DEFN:
lineno = TREE_COMPLEXITY (t);
lineno = STMT_LINENO (t);
t = TREE_TYPE (t);
if (TREE_CODE (t) == ENUMERAL_TYPE)
tsubst (t, args, complain, NULL_TREE);
......
......@@ -741,6 +741,14 @@ finish_asm_stmt (cv_qualifier, string, output_operands,
pop_obstacks ();
}
if (cv_qualifier != NULL_TREE
&& cv_qualifier != ridpointers[(int) RID_VOLATILE])
{
cp_warning ("%s qualifier ignored on asm",
IDENTIFIER_POINTER (cv_qualifier));
cv_qualifier = NULL_TREE;
}
if (processing_template_decl)
{
tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
......@@ -756,30 +764,17 @@ finish_asm_stmt (cv_qualifier, string, output_operands,
{
tree t;
if (cv_qualifier != NULL_TREE
&& cv_qualifier != ridpointers[(int) RID_VOLATILE])
cp_warning ("%s qualifier ignored on asm",
IDENTIFIER_POINTER (cv_qualifier));
for (t = input_operands; t; t = TREE_CHAIN (t))
TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
c_expand_asm_operands (string, output_operands,
input_operands,
clobbers,
cv_qualifier
== ridpointers[(int) RID_VOLATILE],
cv_qualifier != NULL_TREE,
input_filename, lineno);
}
else
{
/* Don't warn about redundant specification of 'volatile' here. */
if (cv_qualifier != NULL_TREE
&& cv_qualifier != ridpointers[(int) RID_VOLATILE])
cp_warning ("%s qualifier ignored on asm",
IDENTIFIER_POINTER (cv_qualifier));
expand_asm (string);
}
expand_asm (string);
finish_stmt ();
}
......
......@@ -139,8 +139,8 @@ in the following sections.
@item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@smallexample
-a -ax -d@var{letters} -fdump-unnumbered -fpretend-float
-fprofile-arcs -ftest-coverage
-a -ax -d@var{letters} -fdump-unnumbered -fdump-translation-unit-@var{file}
-fpretend-float -fprofile-arcs -ftest-coverage
-g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2
-ggdb -gstabs -gstabs+ -gxcoff -gxcoff+
-p -pg -print-file-name=@var{library} -print-libgcc-file-name
......@@ -2120,6 +2120,10 @@ numbers and line number note output. This makes it more feasible to
use diff on debugging dumps for compiler invokations with different
options, in particular with and without -g.
@item -fdump-translation-unit-@var{file} (C++ only)
Dump a representation of the tree structure for the entire translation
unit to @var{file}.
@item -fpretend-float
When running a cross-compiler, pretend that the target machine uses the
same floating point format as the host machine. This causes incorrect
......
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