diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-07-21 00:27:51 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-07-21 00:27:51 +0000 |
commit | 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518 (patch) | |
tree | 9eb091e90a6d0a753271dc34499ed1179b3527ca /gcc/c-family/c-ada-spec.c | |
parent | 61612fa5daee514e736102d0bdfb5a4eec391430 (diff) | |
download | gcc-5aaa8fb40681ee66282d73dab8c8eccbf5ee0518.zip gcc-5aaa8fb40681ee66282d73dab8c8eccbf5ee0518.tar.gz gcc-5aaa8fb40681ee66282d73dab8c8eccbf5ee0518.tar.bz2 |
Remove TYPE_METHODS.
gcc/
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.
From-SVN: r250413
Diffstat (limited to 'gcc/c-family/c-ada-spec.c')
-rw-r--r-- | gcc/c-family/c-ada-spec.c | 112 |
1 files changed, 46 insertions, 66 deletions
diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 6cf298a..d39501c 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -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; @@ -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; @@ -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; @@ -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 @@ -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; } @@ -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"); @@ -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; + } } } |