Skip to content

Commit

Permalink
gcc/
Browse files Browse the repository at this point in the history
	Remove TYPE_METHODS.
	* tree.h (TYPE_METHODS): Delete.
	* dwarf2out.c (gen_member_die): Member fns are on TYPE_FIELDS.
	* dbxout.c (dbxout_type_fields): Ignore FUNCTION_DECLs.
	(dbxout_type_methods): Scan TYPE_FIELDS.
	(dbxout_type): Don't check TYPE_METHODS here.
	* function.c (use_register_for_decl): Always ignore register for
	class types when not optimizing.
	* ipa-devirt.c (odr_types_equivalent_p): Delete TYPE_METHODS scan.
	* tree.c (free_lang_data_in_type): Stitch out member functions and
	templates from TYPE_FIELDS.
	(build_distinct_type_copy, verify_type_variant,
	verify_type): Member fns are on TYPE_FIELDS.
	* tree-dump.c (dequeue_and_dump): No TYPE_METHODS.
	* tree-pretty-print.c (dump_generic_node): Likewise.

	gcc/cp/
	Remove TYPE_METHODS.
	* class.c (maybe_warn_about_overly_private_class,
	finish_struct_methods, one_inheriting_sig, count_fields,
	add_fields_to_record_type, check_field_decls, check_methods,
	clone_function_decl, set_method_tm_attributes,
	finalize_literal_type_property, check_bases_and_members,
	create_vtable_ptr, determine_key_method,
	unreverse_member_declarations, finish_struct,
	add_vcall_offset_vtbl_entries_1): Member fns are on TYPE_FIELDS.
	* decl.c (fixup_anonymous_aggr): Likewise.
	* decl2.c (reset_type_linkage_2): Likewise.
	* method.c (after_nsdmi_defaulted_late_checks,
	lazily_declare_fn): Likewise.
	* optimize.c (maybe_thunk_body, maybe_clone_body): Likewise.
	* pt.c (instantiate_class_template_1, tsubst_expr,
	do_type_instantiation, instantiate_pending_templates): Likewise.
	* search.c (lookup_field_1): Likewise.
	* semantics.c (finish_member_declaration,
	finish_omp_declare_simd_methods): Likewise.

	gcc/c-family/
	Remove TYPE_METHODS.
	* c-ada-spec.c (is_tagged_type, has_nontrivial_methods,
	dump_ada_template, print_ada_methods,
	print_ada_declaration): Member fns are on TYPE_FIELDS.

	gcc/objc/
	Remove TYPE_METHODS.
	* objc-runtime-shared-support.c (build_ivar_list_initializer):
	Don't presume first item is a FIELD_DECL.

	gcc/testsuite/
	* g++.dg/ext/anon-struct6.C: Adjust diag.
	* g++.old-deja/g++.other/anon4.C: Adjust diag.

	libcc1/
	Remove TYPE_METHODS.
	* libcp1plugin.cc (plugin_build_decl): Member fns are on TYPE_FIELDS.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250413 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
nathan committed Jul 21, 2017
1 parent 8a6284f commit ab87ee8
Show file tree
Hide file tree
Showing 27 changed files with 360 additions and 463 deletions.
18 changes: 18 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2017-07-20 Nathan Sidwell <nathan@acm.org>

Remove TYPE_METHODS.
* tree.h (TYPE_METHODS): Delete.
* dwarf2out.c (gen_member_die): Member fns are on TYPE_FIELDS.
* dbxout.c (dbxout_type_fields): Ignore FUNCTION_DECLs.
(dbxout_type_methods): Scan TYPE_FIELDS.
(dbxout_type): Don't check TYPE_METHODS here.
* function.c (use_register_for_decl): Always ignore register for
class types when not optimizing.
* ipa-devirt.c (odr_types_equivalent_p): Delete TYPE_METHODS scan.
* tree.c (free_lang_data_in_type): Stitch out member functions and
templates from TYPE_FIELDS.
(build_distinct_type_copy, verify_type_variant,
verify_type): Member fns are on TYPE_FIELDS.
* tree-dump.c (dequeue_and_dump): No TYPE_METHODS.
* tree-pretty-print.c (dump_generic_node): Likewise.

2017-07-20 Jakub Jelinek <jakub@redhat.com>

PR target/80846
Expand Down
7 changes: 7 additions & 0 deletions gcc/c-family/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2017-07-20 Nathan Sidwell <nathan@acm.org>

Remove TYPE_METHODS.
* c-ada-spec.c (is_tagged_type, has_nontrivial_methods,
dump_ada_template, print_ada_methods,
print_ada_declaration): Member fns are on TYPE_FIELDS.

2017-07-18 Nathan Sidwell <nathan@acm.org>

* c-warn.c (warn_for_memset): Use TYPE_{MIN,MAX}_VALUE.
Expand Down
112 changes: 46 additions & 66 deletions gcc/c-family/c-ada-spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,16 +1070,11 @@ has_static_fields (const_tree type)
static bool
is_tagged_type (const_tree type)
{
tree tmp;

if (!type || !RECORD_OR_UNION_TYPE_P (type))
return false;

/* TYPE_METHODS is only set on the main variant. */
type = TYPE_MAIN_VARIANT (type);

for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp))
if (TREE_CODE (tmp) == FUNCTION_DECL && DECL_VINDEX (tmp))
for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
if (TREE_CODE (fld) == FUNCTION_DECL && DECL_VINDEX (fld))
return true;

return false;
Expand All @@ -1093,8 +1088,6 @@ is_tagged_type (const_tree type)
static bool
has_nontrivial_methods (tree type)
{
tree tmp;

if (!type || !RECORD_OR_UNION_TYPE_P (type))
return false;

Expand All @@ -1106,12 +1099,9 @@ has_nontrivial_methods (tree type)
if (!cpp_check (type, IS_TRIVIAL))
return true;

/* TYPE_METHODS is only set on the main variant. */
type = TYPE_MAIN_VARIANT (type);

/* If there are user-defined methods, they are deemed non-trivial. */
for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp))
if (!DECL_ARTIFICIAL (tmp))
for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE && !DECL_ARTIFICIAL (fld))
return true;

return false;
Expand Down Expand Up @@ -1896,7 +1886,7 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc)
if (TREE_VEC_LENGTH (types) == 0)
break;

if (!RECORD_OR_UNION_TYPE_P (instance) || !TYPE_METHODS (instance))
if (!RECORD_OR_UNION_TYPE_P (instance))
break;

/* We are interested in concrete template instantiations only: skip
Expand Down Expand Up @@ -2442,25 +2432,23 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
static int
print_ada_methods (pretty_printer *buffer, tree node, int spc)
{
tree t;
int res;

if (!has_nontrivial_methods (node))
return 0;

pp_semicolon (buffer);

res = 1;
for (t = TYPE_METHODS (node); t; t = TREE_CHAIN (t))
{
if (res)
{
pp_newline (buffer);
pp_newline (buffer);
}

res = print_ada_declaration (buffer, t, node, spc);
}
int res = 1;
for (tree fld = TYPE_FIELDS (node); fld; fld = DECL_CHAIN (fld))
if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE)
{
if (res)
{
pp_newline (buffer);
pp_newline (buffer);
}

res = print_ada_declaration (buffer, fld, node, spc);
}

return 1;
}
Expand Down Expand Up @@ -2961,19 +2949,13 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
dump_generic_ada_node (buffer, ret_type, type, spc, false, true);
}

if (is_constructor
&& RECORD_OR_UNION_TYPE_P (type)
&& TYPE_METHODS (type))
{
tree tmp;

for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp))
if (cpp_check (tmp, IS_ABSTRACT))
{
is_abstract_class = true;
break;
}
}
if (is_constructor && RECORD_OR_UNION_TYPE_P (type))
for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
if (cpp_check (fld, IS_ABSTRACT))
{
is_abstract_class = true;
break;
}

if (is_abstract || is_abstract_class)
pp_string (buffer, " is abstract");
Expand Down Expand Up @@ -3028,35 +3010,33 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)

pp_string (buffer, " is ");

/* Check whether we have an Ada interface compatible class. */
/* Check whether we have an Ada interface compatible class.
That is only have a vtable non-static data member and no
non-abstract methods. */
if (cpp_check
&& RECORD_OR_UNION_TYPE_P (TREE_TYPE (t))
&& TYPE_METHODS (TREE_TYPE (t)))
&& RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)))
{
int num_fields = 0;
tree tmp;
is_interface = -1;

/* Check that there are no fields other than the virtual table. */
for (tmp = TYPE_FIELDS (TREE_TYPE (t)); tmp; tmp = TREE_CHAIN (tmp))
{
if (TREE_CODE (tmp) == TYPE_DECL)
continue;
num_fields++;
}

if (num_fields == 1)
is_interface = 1;

/* Also check that there are only pure virtual methods. Since the
class is empty, we can skip implicit constructors/destructors. */
for (tmp = TYPE_METHODS (TREE_TYPE (t)); tmp; tmp = TREE_CHAIN (tmp))
for (tree fld = TYPE_FIELDS (TREE_TYPE (t));
fld; fld = TREE_CHAIN (fld))
{
if (DECL_ARTIFICIAL (tmp))
continue;
if (cpp_check (tmp, IS_ABSTRACT))
is_abstract_record = 1;
else
is_interface = 0;
if (TREE_CODE (fld) == FIELD_DECL)
{
if (is_interface < 0 && DECL_VIRTUAL_P (fld))
is_interface = 1;
else
is_interface = 0;
}
else if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE
&& !DECL_ARTIFICIAL (fld))
{
if (cpp_check (fld, IS_ABSTRACT))
is_abstract_record = 1;
else
is_interface = 0;
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
2017-07-20 Nathan Sidwell <nathan@acm.org>

Remove TYPE_METHODS.
* class.c (maybe_warn_about_overly_private_class,
finish_struct_methods, one_inheriting_sig, count_fields,
add_fields_to_record_type, check_field_decls, check_methods,
clone_function_decl, set_method_tm_attributes,
finalize_literal_type_property, check_bases_and_members,
create_vtable_ptr, determine_key_method,
unreverse_member_declarations, finish_struct,
add_vcall_offset_vtbl_entries_1): Member fns are on TYPE_FIELDS.
* decl.c (fixup_anonymous_aggr): Likewise.
* decl2.c (reset_type_linkage_2): Likewise.
* method.c (after_nsdmi_defaulted_late_checks,
lazily_declare_fn): Likewise.
* optimize.c (maybe_thunk_body, maybe_clone_body): Likewise.
* pt.c (instantiate_class_template_1, tsubst_expr,
do_type_instantiation, instantiate_pending_templates): Likewise.
* search.c (lookup_field_1): Likewise.
* semantics.c (finish_member_declaration,
finish_omp_declare_simd_methods): Likewise.

2017-07-19 Nathan Sidwell <nathan@acm.org>

* class.c (add_implicitly_declared_members): Use
Expand Down
Loading

0 comments on commit ab87ee8

Please sign in to comment.