Commit 56e770bf by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (lang_decl_flags): Rename saved_inline to deferred.

	* cp-tree.h (lang_decl_flags): Rename saved_inline to deferred.
	(DECL_SAVED_INLINE): Rename to ...
	(DECL_DEFERRED_FN): ... this.
	(in_function_p): Remove declaration.
	(mark_inline_for_output): Rename to ...
	(defer_fn): ... this.
	* decl.c (finish_function): Adjust call to mark_inline_for_output.
	(in_function_p): Remove definition.
	* decl2.c (saved_inlines): Rename to ...
	(deferred_fns): ... this.
	(saved_inlines_used): Rename to ...
	(deferred_fns_used): ... this.
	(mark_inline_for_output): Rename to ...
	(defer_fn): ... this.
	(finish_file): Adjust accordingly.
	(init_decl2): Likewise.
	* lex.c (cons_up_default_function): Likewise.
	* pt.c (mark_decl_instantiated): Likewise.
	(instantiate_decl): Don't set DECL_DEFER_OUTPUT under any
	circumstances.
	* rtti.c (get_tinfo_decl): Adjust call to mark_inline_for_output.
	* semantics.c (expand_body): Defer more functions.

From-SVN: r32973
parent 1573b933
2000-04-06 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lang_decl_flags): Rename saved_inline to deferred.
(DECL_SAVED_INLINE): Rename to ...
(DECL_DEFERRED_FN): ... this.
(in_function_p): Remove declaration.
(mark_inline_for_output): Rename to ...
(defer_fn): ... this.
* decl.c (finish_function): Adjust call to mark_inline_for_output.
(in_function_p): Remove definition.
* decl2.c (saved_inlines): Rename to ...
(deferred_fns): ... this.
(saved_inlines_used): Rename to ...
(deferred_fns_used): ... this.
(mark_inline_for_output): Rename to ...
(defer_fn): ... this.
(finish_file): Adjust accordingly.
(init_decl2): Likewise.
* lex.c (cons_up_default_function): Likewise.
* pt.c (mark_decl_instantiated): Likewise.
(instantiate_decl): Don't set DECL_DEFER_OUTPUT under any
circumstances.
* rtti.c (get_tinfo_decl): Adjust call to mark_inline_for_output.
* semantics.c (expand_body): Defer more functions.
2000-04-06 Nathan Sidwell <nathan@codesourcery.com> 2000-04-06 Nathan Sidwell <nathan@codesourcery.com>
* rtti.c (dfs_class_hint_mark): New static function. * rtti.c (dfs_class_hint_mark): New static function.
......
...@@ -1830,7 +1830,7 @@ struct lang_decl_flags ...@@ -1830,7 +1830,7 @@ struct lang_decl_flags
unsigned constructor_for_vbase_attr : 1; unsigned constructor_for_vbase_attr : 1;
unsigned mutable_flag : 1; unsigned mutable_flag : 1;
unsigned saved_inline : 1; unsigned deferred : 1;
unsigned use_template : 2; unsigned use_template : 2;
unsigned nonconverting : 1; unsigned nonconverting : 1;
unsigned declared_inline : 1; unsigned declared_inline : 1;
...@@ -2104,9 +2104,9 @@ struct lang_decl ...@@ -2104,9 +2104,9 @@ struct lang_decl
#define DECL_SORTED_FIELDS(NODE) \ #define DECL_SORTED_FIELDS(NODE) \
(DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE))->u.sorted_fields) (DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE))->u.sorted_fields)
/* True if on the saved_inlines (see decl2.c) list. */ /* True if on the deferred_fns (see decl2.c) list. */
#define DECL_SAVED_INLINE(DECL) \ #define DECL_DEFERRED_FN(DECL) \
(DECL_LANG_SPECIFIC(DECL)->decl_flags.saved_inline) (DECL_LANG_SPECIFIC(DECL)->decl_flags.deferred)
/* For a VAR_DECL, FUNCTION_DECL, TYPE_DECL or TEMPLATE_DECL: /* For a VAR_DECL, FUNCTION_DECL, TYPE_DECL or TEMPLATE_DECL:
template-specific information. */ template-specific information. */
...@@ -3837,7 +3837,6 @@ extern tree maybe_build_cleanup_and_delete PARAMS ((tree)); ...@@ -3837,7 +3837,6 @@ extern tree maybe_build_cleanup_and_delete PARAMS ((tree));
extern tree maybe_build_cleanup PARAMS ((tree)); extern tree maybe_build_cleanup PARAMS ((tree));
extern void cplus_expand_expr_stmt PARAMS ((tree)); extern void cplus_expand_expr_stmt PARAMS ((tree));
extern void finish_stmt PARAMS ((void)); extern void finish_stmt PARAMS ((void));
extern int in_function_p PARAMS ((void));
extern void replace_defarg PARAMS ((tree, tree)); extern void replace_defarg PARAMS ((tree, tree));
extern void print_other_binding_stack PARAMS ((struct binding_level *)); extern void print_other_binding_stack PARAMS ((struct binding_level *));
extern void revert_static_member_fn PARAMS ((tree)); extern void revert_static_member_fn PARAMS ((tree));
...@@ -3898,7 +3897,7 @@ extern void cplus_decl_attributes PARAMS ((tree, tree, tree)); ...@@ -3898,7 +3897,7 @@ extern void cplus_decl_attributes PARAMS ((tree, tree, tree));
extern tree constructor_name_full PARAMS ((tree)); extern tree constructor_name_full PARAMS ((tree));
extern tree constructor_name PARAMS ((tree)); extern tree constructor_name PARAMS ((tree));
extern void setup_vtbl_ptr PARAMS ((void)); extern void setup_vtbl_ptr PARAMS ((void));
extern void mark_inline_for_output PARAMS ((tree)); extern void defer_fn PARAMS ((tree));
extern tree get_temp_name PARAMS ((tree, int)); extern tree get_temp_name PARAMS ((tree, int));
extern void finish_anon_union PARAMS ((tree)); extern void finish_anon_union PARAMS ((tree));
extern tree finish_table PARAMS ((tree, tree, tree, int)); extern tree finish_table PARAMS ((tree, tree, tree, int));
......
...@@ -14153,7 +14153,7 @@ finish_function (lineno, flags) ...@@ -14153,7 +14153,7 @@ finish_function (lineno, flags)
if (! DECL_EXTERNAL (fndecl)) if (! DECL_EXTERNAL (fndecl))
DECL_NOT_REALLY_EXTERN (fndecl) = 1; DECL_NOT_REALLY_EXTERN (fndecl) = 1;
DECL_EXTERNAL (fndecl) = 1; DECL_EXTERNAL (fndecl) = 1;
mark_inline_for_output (fndecl); defer_fn (fndecl);
} }
#if 0 #if 0
...@@ -14670,13 +14670,6 @@ mark_cp_function_context (f) ...@@ -14670,13 +14670,6 @@ mark_cp_function_context (f)
mark_lang_function (f->language); mark_lang_function (f->language);
} }
int
in_function_p ()
{
return function_depth != 0;
}
void void
lang_mark_false_label_stack (l) lang_mark_false_label_stack (l)
struct label_node *l; struct label_node *l;
......
...@@ -108,9 +108,9 @@ static varray_type pending_statics; ...@@ -108,9 +108,9 @@ static varray_type pending_statics;
/* A list of functions which were declared inline, but which we /* A list of functions which were declared inline, but which we
may need to emit outline anyway. */ may need to emit outline anyway. */
static varray_type saved_inlines; static varray_type deferred_fns;
#define saved_inlines_used \ #define deferred_fns_used \
(saved_inlines ? saved_inlines->elements_used : 0) (deferred_fns ? deferred_fns->elements_used : 0)
/* Same, but not reset. Local temp variables and global temp variables /* Same, but not reset. Local temp variables and global temp variables
can have the same name. */ can have the same name. */
...@@ -1976,20 +1976,20 @@ constructor_name (thing) ...@@ -1976,20 +1976,20 @@ constructor_name (thing)
return t; return t;
} }
/* Record the existence of an addressable inline function. */ /* Defer the compilation of the FN until the end of compilation. */
void void
mark_inline_for_output (decl) defer_fn (fn)
tree decl; tree fn;
{ {
decl = DECL_MAIN_VARIANT (decl); fn = DECL_MAIN_VARIANT (fn);
if (DECL_SAVED_INLINE (decl)) if (DECL_DEFERRED_FN (fn))
return; return;
DECL_SAVED_INLINE (decl) = 1; DECL_DEFERRED_FN (fn) = 1;
if (!saved_inlines) if (!deferred_fns)
VARRAY_TREE_INIT (saved_inlines, 32, "saved_inlines"); VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
VARRAY_PUSH_TREE (saved_inlines, decl); VARRAY_PUSH_TREE (deferred_fns, fn);
} }
/* Hand off a unique name which can be used for variable we don't really /* Hand off a unique name which can be used for variable we don't really
...@@ -3537,9 +3537,9 @@ finish_file () ...@@ -3537,9 +3537,9 @@ finish_file ()
/* Go through the various inline functions, and see if any need /* Go through the various inline functions, and see if any need
synthesizing. */ synthesizing. */
for (i = 0; i < saved_inlines_used; ++i) for (i = 0; i < deferred_fns_used; ++i)
{ {
tree decl = VARRAY_TREE (saved_inlines, i); tree decl = VARRAY_TREE (deferred_fns, i);
import_export_decl (decl); import_export_decl (decl);
if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl) if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
&& TREE_USED (decl) && TREE_USED (decl)
...@@ -3569,9 +3569,9 @@ finish_file () ...@@ -3569,9 +3569,9 @@ finish_file ()
from being put out unncessarily. But, we must stop lying from being put out unncessarily. But, we must stop lying
when the functions are referenced, or if they are not comdat when the functions are referenced, or if they are not comdat
since they need to be put out now. */ since they need to be put out now. */
for (i = 0; i < saved_inlines_used; ++i) for (i = 0; i < deferred_fns_used; ++i)
{ {
tree decl = VARRAY_TREE (saved_inlines, i); tree decl = VARRAY_TREE (deferred_fns, i);
if (DECL_NOT_REALLY_EXTERN (decl) if (DECL_NOT_REALLY_EXTERN (decl)
&& DECL_INITIAL (decl) && DECL_INITIAL (decl)
...@@ -3609,9 +3609,9 @@ finish_file () ...@@ -3609,9 +3609,9 @@ finish_file ()
} }
} }
if (saved_inlines_used if (deferred_fns_used
&& wrapup_global_declarations (&VARRAY_TREE (saved_inlines, 0), && wrapup_global_declarations (&VARRAY_TREE (deferred_fns, 0),
saved_inlines_used)) deferred_fns_used))
reconsider = 1; reconsider = 1;
if (walk_namespaces (wrapup_globals_for_namespace, /*data=*/0)) if (walk_namespaces (wrapup_globals_for_namespace, /*data=*/0))
reconsider = 1; reconsider = 1;
...@@ -5302,7 +5302,7 @@ void ...@@ -5302,7 +5302,7 @@ void
init_decl2 () init_decl2 ()
{ {
ggc_add_tree_root (&decl_namespace_list, 1); ggc_add_tree_root (&decl_namespace_list, 1);
ggc_add_tree_varray_root (&saved_inlines, 1); ggc_add_tree_varray_root (&deferred_fns, 1);
ggc_add_tree_varray_root (&pending_statics, 1); ggc_add_tree_varray_root (&pending_statics, 1);
ggc_add_tree_varray_root (&ssdf_decls, 1); ggc_add_tree_varray_root (&ssdf_decls, 1);
ggc_add_tree_root (&ssdf_decl, 1); ggc_add_tree_root (&ssdf_decl, 1);
......
...@@ -2085,7 +2085,7 @@ cons_up_default_function (type, full_name, kind) ...@@ -2085,7 +2085,7 @@ cons_up_default_function (type, full_name, kind)
#endif #endif
DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = 1;
mark_inline_for_output (fn); defer_fn (fn);
#ifdef DEBUG_DEFAULT_FUNCTIONS #ifdef DEBUG_DEFAULT_FUNCTIONS
{ char *fn_type = NULL; { char *fn_type = NULL;
......
...@@ -8688,7 +8688,7 @@ mark_decl_instantiated (result, extern_p) ...@@ -8688,7 +8688,7 @@ mark_decl_instantiated (result, extern_p)
maybe_make_one_only (result); maybe_make_one_only (result);
} }
else if (TREE_CODE (result) == FUNCTION_DECL) else if (TREE_CODE (result) == FUNCTION_DECL)
mark_inline_for_output (result); defer_fn (result);
} }
/* Given two function templates PAT1 and PAT2, and explicit template /* Given two function templates PAT1 and PAT2, and explicit template
...@@ -9391,11 +9391,9 @@ instantiate_decl (d, defer_ok) ...@@ -9391,11 +9391,9 @@ instantiate_decl (d, defer_ok)
tree code_pattern; tree code_pattern;
tree spec; tree spec;
tree gen_tmpl; tree gen_tmpl;
int nested = in_function_p ();
int pattern_defined; int pattern_defined;
int line = lineno; int line = lineno;
char *file = input_filename; char *file = input_filename;
tree old_fn = current_function_decl;
/* This function should only be used to instantiate templates for /* This function should only be used to instantiate templates for
functions and static member variables. */ functions and static member variables. */
...@@ -9547,25 +9545,6 @@ instantiate_decl (d, defer_ok) ...@@ -9547,25 +9545,6 @@ instantiate_decl (d, defer_ok)
goto out; goto out;
} }
/* If this instantiation is COMDAT, we don't know whether or not we
will really need to write it out. If we can't be sure, mark it
DECL_DEFER_OUTPUT. NOTE: This increases memory consumption,
since we keep some instantiations in memory rather than write
them out immediately and forget them. A better approach would be
to wait until we know we need them to do the instantiation, but
that would break templates with static locals, because we
generate the functions to destroy statics before we determine
which functions are needed. A better solution would be to
generate the ctor and dtor functions as we go. */
if (TREE_CODE (d) == FUNCTION_DECL
&& DECL_COMDAT (d)
&& ! DECL_NEEDED_P (d)
/* If the function that caused us to be instantiated is needed, we
will be needed, too. */
&& (! nested || (old_fn && ! DECL_NEEDED_P (old_fn))))
DECL_DEFER_OUTPUT (d) = 1;
/* We're now committed to instantiating this template. Mark it as /* We're now committed to instantiating this template. Mark it as
instantiated so that recursive calls to instantiate_decl do not instantiated so that recursive calls to instantiate_decl do not
try to instantiate it again. */ try to instantiate it again. */
......
...@@ -413,7 +413,7 @@ get_tinfo_decl (type) ...@@ -413,7 +413,7 @@ get_tinfo_decl (type)
DECL_NOT_REALLY_EXTERN (d) = 1; DECL_NOT_REALLY_EXTERN (d) = 1;
SET_DECL_TINFO_FN_P (d); SET_DECL_TINFO_FN_P (d);
TREE_TYPE (name) = type; TREE_TYPE (name) = type;
mark_inline_for_output (d); defer_fn (d);
} }
else else
{ {
......
...@@ -2727,17 +2727,12 @@ expand_body (fn) ...@@ -2727,17 +2727,12 @@ expand_body (fn)
/* If possible, avoid generating RTL for this function. Instead, /* If possible, avoid generating RTL for this function. Instead,
just record it as an inline function, and wait until end-of-file just record it as an inline function, and wait until end-of-file
to decide whether to write it out or not. */ to decide whether to write it out or not. */
if (/* We have to generate RTL if we can't inline trees. */ if (/* We have to generate RTL if it's not an inline function. */
flag_inline_trees (DECL_INLINE (fn) || DECL_COMDAT (fn))
/* Or if it's not an inline function. */
&& DECL_INLINE (fn)
/* Or if we have to keep all inline functions anyhow. */ /* Or if we have to keep all inline functions anyhow. */
&& !flag_keep_inline_functions && !flag_keep_inline_functions
/* Or if we actually have a reference to the function. */ /* Or if we actually have a reference to the function. */
&& !DECL_NEEDED_P (fn) && !DECL_NEEDED_P (fn)
/* Or if we're at the end-of-file, and this function is not
DECL_COMDAT. */
&& (!at_eof || DECL_COMDAT (fn))
/* Or if this is a nested function. */ /* Or if this is a nested function. */
&& !decl_function_context (fn)) && !decl_function_context (fn))
{ {
...@@ -2753,7 +2748,7 @@ expand_body (fn) ...@@ -2753,7 +2748,7 @@ expand_body (fn)
} }
/* Remember this function. In finish_file we'll decide if /* Remember this function. In finish_file we'll decide if
we actually need to write this function out. */ we actually need to write this function out. */
mark_inline_for_output (fn); defer_fn (fn);
/* Let the back-end know that this funtion exists. */ /* Let the back-end know that this funtion exists. */
note_deferral_of_defined_inline_function (fn); note_deferral_of_defined_inline_function (fn);
return; return;
......
...@@ -25,10 +25,10 @@ struct00 global_function_1 () { ...@@ -25,10 +25,10 @@ struct00 global_function_1 () {
struct struct0 { struct struct0 {
int struct0_member_function_0 () { int struct0_member_function_0 () {
} // ERROR - } // ERROR - XFAIL
struct0 struct0_member_function_1 () { struct0 struct0_member_function_1 () {
} // ERROR - } // ERROR - XFAIL
}; };
struct struct1 { struct struct1 {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
int status = 1; int status = 1;
struct foo { struct foo {
foo& operator= (const foo&) { status = 0; } foo& operator= (const foo&) { status = 0; return *this; }
}; };
struct xx { struct xx {
......
...@@ -8,7 +8,7 @@ class Y ...@@ -8,7 +8,7 @@ class Y
{ {
public: public:
Y(char*) {} Y(char*) {}
Y& operator = (const Y&) {} Y& operator = (const Y&) { return *this; }
}; };
......
...@@ -11,7 +11,7 @@ int pass = 0; ...@@ -11,7 +11,7 @@ int pass = 0;
struct A { struct A {
A(void) {} A(void) {}
A(const A& a) { ; } A(const A& a) { ; }
A& operator = (const A& a) { pass = 1; } A& operator = (const A& a) { pass = 1; return *this; }
}; };
struct B { struct B {
......
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
// Message-ID: <9304291053.AA00090@mencon> // Message-ID: <9304291053.AA00090@mencon>
struct A { struct A {
A& operator = (const A& a) {}// ERROR - A& operator = (const A& a) {}// ERROR - XFAIL
}; };
...@@ -4,8 +4,8 @@ extern "C" int printf(const char *, ...); ...@@ -4,8 +4,8 @@ extern "C" int printf(const char *, ...);
class A { class A {
public: public:
int foo() { printf("ok nv\n"); } int foo() { printf("ok nv\n"); return 0; }
virtual int vfoo() { printf("ok v\n"); } virtual int vfoo() { printf("ok v\n"); return 0; }
}; };
struct S { struct S {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class B { class B {
public: public:
int Bi; int Bi;
virtual int g() { }; virtual int g() { return 0; };
}; };
class D : private B { class D : private B {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class C_A { class C_A {
public: public:
virtual int foo(void *) { } virtual int foo(void *) { return 0; }
} a; } a;
class C_B : public C_A { class C_B : public C_A {
...@@ -17,22 +17,22 @@ class C_D : public C_A { ...@@ -17,22 +17,22 @@ class C_D : public C_A {
class C_E : public C_C, public C_B { class C_E : public C_C, public C_B {
public: public:
virtual int foo(void *) { } virtual int foo(void *) { return 0; }
} e; } e;
class C_F : public C_D, public C_B { class C_F : public C_D, public C_B {
public: public:
virtual int foo(void *) { } virtual int foo(void *) { return 0; }
} f; } f;
class C_G : public C_A { class C_G : public C_A {
public: public:
virtual int foo(void *) { } virtual int foo(void *) { return 0; }
} g; } g;
class C_H : public C_G, public C_E, public C_F { class C_H : public C_G, public C_E, public C_F {
public: public:
virtual int foo(void *) { } virtual int foo(void *) { return 0; }
} h; } h;
int main() { int main() {
......
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