Commit 5524676d by Jason Merrill Committed by Jason Merrill

decl.c (struct cp_function): Add named_label_uses.

	* decl.c (struct cp_function): Add named_label_uses.
	(push_cp_function_context): Save it.
	(pop_cp_function_context): Restore it.
	(define_label): Also complain about jumping into the scope of
	non-POD objects that don't have constructors.
	* tree.c (pod_type_p): New fn.
Fixes g++.other/init9.C
	* pt.c (instantiate_class_template): Clear TYPE_BEING_DEFINED sooner.
	* rtti.c (synthesize_tinfo_fn): Call import_export_decl here.
	(get_tinfo_fn): Not here.
	* repo.c (repo_get_id): Abort if we get called for an incomplete
	type.
Fixes g++.pt/instantiate4.C

From-SVN: r23667
parent 233363cb
1998-11-15 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (struct cp_function): Add named_label_uses.
(push_cp_function_context): Save it.
(pop_cp_function_context): Restore it.
(define_label): Also complain about jumping into the scope of
non-POD objects that don't have constructors.
* tree.c (pod_type_p): New fn.
* pt.c (instantiate_class_template): Clear TYPE_BEING_DEFINED sooner.
* rtti.c (synthesize_tinfo_fn): Call import_export_decl here.
(get_tinfo_fn): Not here.
* repo.c (repo_get_id): Abort if we get called for an incomplete
type.
1998-11-13 Mark Mitchell <mark@markmitchell.com> 1998-11-13 Mark Mitchell <mark@markmitchell.com>
* except.c (expand_throw): Make sure first argument to * except.c (expand_throw): Make sure first argument to
......
...@@ -4346,9 +4346,8 @@ define_label (filename, line, name) ...@@ -4346,9 +4346,8 @@ define_label (filename, line, name)
and they should be cleaned up and they should be cleaned up
by the time we get to the label. */ by the time we get to the label. */
&& ! DECL_ARTIFICIAL (new_decls) && ! DECL_ARTIFICIAL (new_decls)
&& ((DECL_INITIAL (new_decls) != NULL_TREE && !(DECL_INITIAL (new_decls) == NULL_TREE
&& DECL_INITIAL (new_decls) != error_mark_node) && pod_type_p (TREE_TYPE (new_decls))))
|| TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls))))
{ {
if (! identified) if (! identified)
{ {
...@@ -4358,8 +4357,13 @@ define_label (filename, line, name) ...@@ -4358,8 +4357,13 @@ define_label (filename, line, name)
" from here"); " from here");
identified = 1; identified = 1;
} }
cp_error_at (" crosses initialization of `%#D'", if (DECL_INITIAL (new_decls)
new_decls); || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls)))
cp_error_at (" crosses initialization of `%#D'",
new_decls);
else
cp_error_at (" enters scope of non-POD `%#D'",
new_decls);
} }
new_decls = TREE_CHAIN (new_decls); new_decls = TREE_CHAIN (new_decls);
} }
...@@ -13999,6 +14003,7 @@ struct cp_function ...@@ -13999,6 +14003,7 @@ struct cp_function
int parms_stored; int parms_stored;
int temp_name_counter; int temp_name_counter;
tree named_labels; tree named_labels;
struct named_label_list *named_label_uses;
tree shadowed_labels; tree shadowed_labels;
tree ctor_label; tree ctor_label;
tree dtor_label; tree dtor_label;
...@@ -14035,6 +14040,7 @@ push_cp_function_context (context) ...@@ -14035,6 +14040,7 @@ push_cp_function_context (context)
cp_function_chain = p; cp_function_chain = p;
p->named_labels = named_labels; p->named_labels = named_labels;
p->named_label_uses = named_label_uses;
p->shadowed_labels = shadowed_labels; p->shadowed_labels = shadowed_labels;
p->returns_value = current_function_returns_value; p->returns_value = current_function_returns_value;
p->returns_null = current_function_returns_null; p->returns_null = current_function_returns_null;
...@@ -14077,6 +14083,7 @@ pop_cp_function_context (context) ...@@ -14077,6 +14083,7 @@ pop_cp_function_context (context)
cp_function_chain = p->next; cp_function_chain = p->next;
named_labels = p->named_labels; named_labels = p->named_labels;
named_label_uses = p->named_label_uses;
shadowed_labels = p->shadowed_labels; shadowed_labels = p->shadowed_labels;
current_function_returns_value = p->returns_value; current_function_returns_value = p->returns_value;
current_function_returns_null = p->returns_null; current_function_returns_null = p->returns_null;
......
...@@ -4786,6 +4786,8 @@ instantiate_class_template (type) ...@@ -4786,6 +4786,8 @@ instantiate_class_template (type)
type = finish_struct_1 (type, 0); type = finish_struct_1 (type, 0);
CLASSTYPE_GOT_SEMICOLON (type) = 1; CLASSTYPE_GOT_SEMICOLON (type) = 1;
/* Clear this now so repo_template_used is happy. */
TYPE_BEING_DEFINED (type) = 0;
repo_template_used (type); repo_template_used (type);
end: end:
......
...@@ -99,6 +99,12 @@ repo_get_id (t) ...@@ -99,6 +99,12 @@ repo_get_id (t)
{ {
if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
{ {
/* If we're not done setting up the class, we may not have set up
the vtable, so going ahead would give the wrong answer.
See g++.pt/instantiate4.C. */
if (TYPE_SIZE (t) == NULL_TREE || TYPE_BEING_DEFINED (t))
my_friendly_abort (981113);
t = TYPE_BINFO_VTABLE (t); t = TYPE_BINFO_VTABLE (t);
if (t == NULL_TREE) if (t == NULL_TREE)
return t; return t;
......
...@@ -374,9 +374,6 @@ get_tinfo_fn (type) ...@@ -374,9 +374,6 @@ get_tinfo_fn (type)
make_function_rtl (d); make_function_rtl (d);
assemble_external (d); assemble_external (d);
mark_inline_for_output (d); mark_inline_for_output (d);
if (at_eof)
import_export_decl (d);
pop_obstacks (); pop_obstacks ();
return d; return d;
...@@ -1064,9 +1061,16 @@ synthesize_tinfo_fn (fndecl) ...@@ -1064,9 +1061,16 @@ synthesize_tinfo_fn (fndecl)
tree fndecl; tree fndecl;
{ {
tree type = TREE_TYPE (DECL_NAME (fndecl)); tree type = TREE_TYPE (DECL_NAME (fndecl));
tree tmp, addr; tree tmp, addr, tdecl;
if (at_eof)
{
import_export_decl (fndecl);
if (DECL_REALLY_EXTERN (fndecl))
return;
}
tree tdecl = get_tinfo_var (type); tdecl = get_tinfo_var (type);
DECL_EXTERNAL (tdecl) = 0; DECL_EXTERNAL (tdecl) = 0;
TREE_STATIC (tdecl) = 1; TREE_STATIC (tdecl) = 1;
DECL_COMMON (tdecl) = 1; DECL_COMMON (tdecl) = 1;
......
...@@ -2680,3 +2680,36 @@ is_dummy_object (ob) ...@@ -2680,3 +2680,36 @@ is_dummy_object (ob)
return (TREE_CODE (ob) == NOP_EXPR return (TREE_CODE (ob) == NOP_EXPR
&& TREE_OPERAND (ob, 0) == error_mark_node); && TREE_OPERAND (ob, 0) == error_mark_node);
} }
/* Returns 1 iff type T is a POD type, as defined in [basic.types]. */
int
pod_type_p (t)
tree t;
{
tree f;
while (TREE_CODE (t) == ARRAY_TYPE)
t = TREE_TYPE (t);
if (! IS_AGGR_TYPE (t))
return 1;
if (CLASSTYPE_NON_AGGREGATE (t)
|| TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|| TYPE_HAS_DESTRUCTOR (t))
return 0;
for (f = TYPE_FIELDS (t); f; f = TREE_CHAIN (f))
{
if (TREE_CODE (f) != FIELD_DECL)
continue;
if (TREE_CODE (TREE_TYPE (f)) == REFERENCE_TYPE
|| TYPE_PTRMEMFUNC_P (TREE_TYPE (f))
|| TYPE_PTRMEM_P (TREE_TYPE (f)))
return 0;
}
return 1;
}
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