From 4839de55e2c98619f4919254abb87e2f393aaead Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Thu, 17 Sep 2020 14:27:22 -0400 Subject: c-family: Macro support in -Wmisleading-indentation [PR80076] Currently the -Wmisleading-indentation warning doesn't do any analysis when the guarded statement or the statement after it is produced by a macro. This means we warn for: if (flag) foo (); bar (); but not for: #define BAR bar if (flag) foo (); BAR (); This patch extends the -Wmisleading-indentation implementation to support analyzing such statements and their tokens. This is done in the "natural" way by resolving the location of each of the three tokens to the token's macro expansion point. (Additionally, if the tokens all resolve to the same macro expansion point then we instead use their locations within the macro definition.) When these resolved locations are all different, then we can proceed with applying the warning heuristics to them as if no macros were involved. gcc/c-family/ChangeLog: PR c/80076 * c-indentation.c (should_warn_for_misleading_indentation): Move declarations of local variables closer to their first use. Handle virtual token locations by resolving them to their respective macro expansion points. If all three tokens are produced from the same macro expansion, then instead use their loci within the macro definition. gcc/objc/ChangeLog: PR c/80076 * objc-gnu-runtime-abi-01.c (gnu_runtime_abi_01_get_class_super_ref): Reduce indentation of misleadingly indented return statements. * objc-next-runtime-abi-01.c (next_runtime_abi_01_get_class_super_ref): Likewise. gcc/ChangeLog: PR c/80076 * gensupport.c (alter_attrs_for_subst_insn) : Reduce indentation of misleadingly indented code fragment. * lra-constraints.c (multi_block_pseudo_p): Likewise. * sel-sched-ir.c (merge_fences): Likewise. libcpp/ChangeLog: PR c/80076 * include/line-map.h (first_map_in_common): Declare. * line-map.c (first_map_in_common): Remove static. gcc/testsuite/ChangeLog: PR c/80076 * c-c++-common/Wmisleading-indentation-5.c: New test. --- gcc/objc/objc-gnu-runtime-abi-01.c | 4 ++-- gcc/objc/objc-next-runtime-abi-01.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index d586243..c9959a7 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -821,7 +821,7 @@ gnu_runtime_abi_01_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, ucls_super_ref = objc_build_component_ref (imp->class_decl, get_identifier ("super_class")); - return ucls_super_ref; + return ucls_super_ref; } else { @@ -829,7 +829,7 @@ gnu_runtime_abi_01_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, uucls_super_ref = objc_build_component_ref (imp->meta_decl, get_identifier ("super_class")); - return uucls_super_ref; + return uucls_super_ref; } } diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 5c34fcb..233d89e 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -938,7 +938,7 @@ next_runtime_abi_01_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, ucls_super_ref = objc_build_component_ref (imp->class_decl, get_identifier ("super_class")); - return ucls_super_ref; + return ucls_super_ref; } else { @@ -946,7 +946,7 @@ next_runtime_abi_01_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, uucls_super_ref = objc_build_component_ref (imp->meta_decl, get_identifier ("super_class")); - return uucls_super_ref; + return uucls_super_ref; } } -- cgit v1.1 From 2aad20c094b9ec47c678b4ca219a7342f4f22376 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 18 Sep 2020 00:16:24 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 5d8500c..8970c15 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,12 @@ +2020-09-17 Patrick Palka + + PR c/80076 + * objc-gnu-runtime-abi-01.c + (gnu_runtime_abi_01_get_class_super_ref): Reduce indentation of + misleadingly indented return statements. + * objc-next-runtime-abi-01.c + (next_runtime_abi_01_get_class_super_ref): Likewise. + 2020-01-01 Jakub Jelinek Update copyright years. -- cgit v1.1 From 3696a50beeb73f4ded8a584e76ee16f0bde109b9 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Sat, 19 Sep 2020 07:32:35 -0700 Subject: Change C front end to emit structured loop and switch tree nodes. 2020-08-12 Sandra Loosemore gcc/c * c-decl.c (c_break_label, c_cont_label): Delete, and replace with... (in_statement): New. (start_function): Adjust for above change. (c_push_function_context, c_pop_function_context): Likewise. * c-lang.h (struct language_function): Likewise. * c-objc-common.h (LANG_HOOKS_BLOCK_MAY_FALLTHRU): Define. * c-parser.c (objc_foreach_break_label, objc_foreach_continue_label): New. (c_parser_statement_after_labels): Adjust calls to c_finish_bc_stmt. (c_parser_switch_statement): Adjust break/switch context handling and calls to renamed functions. (c_parser_while_statement): Adjust break/switch context handling and build a WHILE_STMT. (c_parser_do_statement): Ditto, with DO_STMT respectively. (c_parser_for_statement): Ditto, with FOR_STMT respectively. (c_parser_omp_for_loop): Adjust break/switch context handling. * c-tree.h (c_break_label, c_cont_label): Delete. (IN_SWITCH_STMT, IN_ITERATION_STMT): Define. (IN_OMP_BLOCK, IN_OMP_FOR, IN_OBJC_FOREACH): Define. (in_statement, switch_statement_break_seen_p): Declare. (c_start_case, c_finish_case): Renamed to... (c_start_switch, c_finish_switch). (c_finish_bc_stmt): Adjust arguments. * c-typeck.c (build_function_call_vec): Don't try to print statements with %qE format. (struct c_switch): Rename switch_expr field to switch_stmt. Add break_stmt_seen_p field. (c_start_case): Rename to c_start_switch. Build a SWITCH_STMT instead of a SWITCH_EXPR. Update for changes to struct c_switch. (do_case): Update for changes to struct c_switch. (c_finish_case): Rename to c_finish_switch. Update for changes to struct c_switch and change of representation from SWITCH_EXPR to SWITCH_STMT. (c_finish_loop): Delete. (c_finish_bc_stmt): Update to reflect changes to break/continue state representation. Build a BREAK_STMT or CONTINUE_STMT instead of a GOTO_EXPR except for objc foreach loops. gcc/objc * objc-act.c (objc_start_method_definition): Update to reflect changes to break/continue state bookkeeping in C front end. gcc/testsuite/ * gcc.dg/gomp/block-7.c: Update expected error message wording. --- gcc/objc/objc-act.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 54af1cf..31a2cf3 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2050,10 +2050,8 @@ objc_start_method_definition (bool is_class_method, tree decl, tree attributes, return false; #ifndef OBJCPLUS - /* Indicate no valid break/continue context by setting these variables - to some non-null, non-label value. We'll notice and emit the proper - error message in c_finish_bc_stmt. */ - c_break_label = c_cont_label = size_zero_node; + /* Indicate no valid break/continue context. */ + in_statement = 0; #endif if (attributes) -- cgit v1.1 From 2fe5b7d1f66457c637b8bd2543a60a5faff34c40 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 20 Sep 2020 00:16:23 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 8970c15..fd36c3d 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2020-09-19 Sandra Loosemore + + * objc-act.c (objc_start_method_definition): Update to reflect + changes to break/continue state bookkeeping in C front end. + 2020-09-17 Patrick Palka PR c/80076 -- cgit v1.1 From 900c0ca22673ec4d382ce588057de240f887be3a Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Thu, 1 Oct 2020 10:58:58 +0100 Subject: Objective-C: Addess a FIXME (NFC). This removes references to the next runtime from the gnu runtime implementation. gcc/objc/ChangeLog: * objc-gnu-runtime-abi-01.c (build_shared_structure_initializer): Remove references to the NeXT runtime. (generate_static_references): Likewise. --- gcc/objc/objc-gnu-runtime-abi-01.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index c9959a7..25c0e01 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -1540,25 +1540,14 @@ build_shared_structure_initializer (tree type, tree isa, tree super, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, expr); } - /* FIXME: Remove NeXT runtime code. */ - if (flag_next_runtime) - { - ltyp = build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier ("objc_cache"))); - /* method_cache = */ - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, convert (ltyp, null_pointer_node)); - } - else - { - /* dtable = */ - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); + /* dtable = */ + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); - /* subclass_list = */ - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); + /* subclass_list = */ + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); - /* sibling_class = */ - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); - } + /* sibling_class = */ + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); /* protocol_list = */ ltyp = build_pointer_type (build_pointer_type (objc_protocol_template)); @@ -1572,11 +1561,6 @@ build_shared_structure_initializer (tree type, tree isa, tree super, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, expr); } - /* FIXME: Remove NeXT runtime code. */ - if (flag_next_runtime) - /* sel_id = NULL */ - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); - /* gc_object_type = NULL */ CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, 0)); @@ -1864,10 +1848,6 @@ generate_static_references (void) char buf[BUFSIZE]; vec *decls = NULL; - /* FIXME: Remove NeXT runtime code. */ - if (flag_next_runtime) - gcc_unreachable (); - for (cl_chain = objc_static_instances, num_class = 0; cl_chain; cl_chain = TREE_CHAIN (cl_chain), num_class++) { -- cgit v1.1 From a788c4555c6d17a5b37516e28844e6fd6013eb3e Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 26 Sep 2020 10:15:28 +0100 Subject: Objective-C, Darwin : Use special string sections for V2 NeXT runtime. Newer versions of the runtime expect to find strings for class, method and method types in set-aside sections rather than the general c_strings one. gcc/ChangeLog: * config/darwin-sections.def (objc2_class_names_section, objc2_method_names_section, objc2_method_types_section): New * config/darwin.c (output_objc_section_asm_op): Output new sections. (darwin_objc2_section): Select new sections where used. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (next_runtime_abi_02_init_metadata_attributes): Attach metadata for the special string sections to class, method and method type string sections. --- gcc/objc/objc-next-runtime-abi-02.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index e401906..b4019cd 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -323,9 +323,10 @@ next_runtime_abi_02_init_metadata_attributes (void) meta_sel_refs = get_identifier ("V2_SRFS"); - meta_class_name = - meta_meth_name = - meta_meth_type = + meta_class_name = get_identifier ("V2_CNAM"); + meta_meth_name = get_identifier ("V2_MNAM"); + + meta_meth_type = get_identifier ("V2_MTYP"); meta_prop_name_attr = get_identifier ("V2_STRG"); meta_mref = get_identifier ("V2_MREF"); -- cgit v1.1 From ecd616f68067cca5e7051c8872b76311b09d8f45 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 3 Oct 2020 13:40:03 +0100 Subject: Objective-C, Darwin : Update metadata section uses. Newer versions of ld64 are more picky about adherence to placement rules for objective c metadata. This adds protocol refs and uses the ivar refs for all targets. gcc/ChangeLog: * config/darwin-sections.def (objc2_data_section): New. (objc2_ivar_section): New. * config/darwin.c (darwin_objc2_section): Act on Protocol and ivar refs. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (next_runtime_abi_02_init_metadata_attributes): Make protocol refs a distinct section. --- gcc/objc/objc-next-runtime-abi-02.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index b4019cd..6d1badc 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -305,8 +305,8 @@ next_runtime_abi_02_init_metadata_attributes (void) meta_class = get_identifier ("G2_CLAS"); meta_metaclass = get_identifier ("G2_META"); - meta_category = - meta_protocol = meta_base; + meta_category = meta_base; + meta_protocol = get_identifier ("V2_PCOL"); meta_clac_vars = meta_clai_vars = meta_base; -- cgit v1.1 From c28d91bf23ad5767265a1298be6fef0caa0a85f0 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Tue, 6 Oct 2020 18:47:26 +0100 Subject: Objective-C, Darwin : Pick up super refs directly. The current code assumed that super refs could be computed indirectly, i.e. that the metadata generated by the compiler was immutable by the runtime. This does not always hold (it depends on the NeXT runtime version). So, compute super refs directly. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (objc_get_superclass_ref_decl): Split this code out. (next_runtime_abi_02_get_class_super_ref): Compute super refs using the objc_get_superclass_ref_decl(). (next_runtime_abi_02_get_category_super_ref): Likewise. --- gcc/objc/objc-next-runtime-abi-02.c | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 6d1badc..5760425 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1439,13 +1439,12 @@ build_v2_superclass_ref_decl (tree ident, bool inst) static GTY (()) vec *class_super_refs; static GTY (()) vec *metaclass_super_refs; +/* Find or build a superclass reference decl for class NAME. */ + static tree -next_runtime_abi_02_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, - struct imp_entry *imp, bool inst_meth) +objc_get_superclass_ref_decl (tree name, bool inst_meth) { tree decl; - ident_data_tuple e; - tree id = CLASS_NAME (imp->imp_context); vec *list = inst_meth ? class_super_refs : metaclass_super_refs; @@ -1455,10 +1454,10 @@ next_runtime_abi_02_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, ident_data_tuple *ref; FOR_EACH_VEC_ELT (*list, count, ref) { - if (ref->ident == id) + if (ref->ident == name) { if (!ref->data) - ref->data = build_v2_superclass_ref_decl (id, inst_meth); + ref->data = build_v2_superclass_ref_decl (name, inst_meth); return ref->data; } } @@ -1479,48 +1478,49 @@ next_runtime_abi_02_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, } /* We come here if we don't find the entry - or if the table was yet to be created. */ - decl = build_v2_superclass_ref_decl (id, inst_meth); - e.ident = id; + decl = build_v2_superclass_ref_decl (name, inst_meth); + ident_data_tuple e; + e.ident = name; e.data = decl; vec_safe_push (list, e); return decl; } +/* Get a reference to the superclass for IMP. */ + static tree -next_runtime_abi_02_get_category_super_ref (location_t loc ATTRIBUTE_UNUSED, - struct imp_entry *imp, bool inst_meth) +next_runtime_abi_02_get_class_super_ref (location_t loc ATTRIBUTE_UNUSED, + struct imp_entry *imp, bool inst_meth) { - /* ??? is this OK when zero-link = true? */ - tree super_name = CLASS_SUPER_NAME (imp->imp_template); - tree super_class; + tree name = CLASS_NAME (imp->imp_context); + return objc_get_superclass_ref_decl (name, inst_meth); +} - if (!flag_zero_link) +/* Get a reference to the superclass for category IMP. */ + +static tree +next_runtime_abi_02_get_category_super_ref (location_t loc ATTRIBUTE_UNUSED, + struct imp_entry *imp, + bool inst_meth) +{ + if (flag_zero_link) { - super_class = objc_get_class_reference (CLASS_NAME (imp->imp_template)); - - if (!inst_meth) - - /* If we are in a class method, we must retrieve the - _metaclass_ for the current class, pointed at by the - class's "isa" pointer. The following assumes that "isa" is - the first ivar in a class (which it must be). */ - super_class = - build_indirect_ref (input_location, - build_c_cast (input_location, - build_pointer_type (objc_class_type), - super_class), - RO_UNARY_STAR); - return super_class; + /* Do it the slow way. */ + tree get_cl_fn = inst_meth ? objc_get_class_decl + : objc_get_meta_class_decl; + tree super_name = CLASS_SUPER_NAME (imp->imp_template); + super_name = my_build_string_pointer (IDENTIFIER_LENGTH (super_name) + 1, + IDENTIFIER_POINTER (super_name)); + /* super_class = objc_get{Meta}Class("CLASS_SUPER_NAME"); */ + return build_function_call (input_location, get_cl_fn, + build_tree_list (NULL_TREE, super_name)); } - /* ??? Do we need to add the class ref anway for zero-link? */ - /* else do it the slow way. */ - super_class = (inst_meth ? objc_get_class_decl : objc_get_meta_class_decl); - super_name = my_build_string_pointer (IDENTIFIER_LENGTH (super_name) + 1, - IDENTIFIER_POINTER (super_name)); - /* super_class = objc_get{Meta}Class("CLASS_SUPER_NAME"); */ - return build_function_call (input_location, - super_class, - build_tree_list (NULL_TREE, super_name)); + + /* This is the 'usual' path. */ + tree cls_name = CLASS_NAME (imp->imp_template); + if (!inst_meth) + return objc_get_superclass_ref_decl (cls_name, inst_meth); + return objc_get_class_reference (cls_name); } static tree -- cgit v1.1 From aab566a4fb69743593bf3b5bd0a48d4e33c01057 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 11 Oct 2020 00:16:25 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index fd36c3d..065dba6 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,31 @@ +2020-10-10 Iain Sandoe + + * objc-next-runtime-abi-02.c + (objc_get_superclass_ref_decl): Split this code out. + (next_runtime_abi_02_get_class_super_ref): Compute + super refs using the objc_get_superclass_ref_decl(). + (next_runtime_abi_02_get_category_super_ref): Likewise. + +2020-10-10 Iain Sandoe + + * objc-next-runtime-abi-02.c + (next_runtime_abi_02_init_metadata_attributes): Make protocol + refs a distinct section. + +2020-10-10 Iain Sandoe + + * objc-next-runtime-abi-02.c + (next_runtime_abi_02_init_metadata_attributes): Attach metadata + for the special string sections to class, method and method type + string sections. + +2020-10-10 Iain Sandoe + + * objc-gnu-runtime-abi-01.c + (build_shared_structure_initializer): Remove references to + the NeXT runtime. + (generate_static_references): Likewise. + 2020-09-19 Sandra Loosemore * objc-act.c (objc_start_method_definition): Update to reflect -- cgit v1.1 From 6224a8aa1ba46218fac36266b9cd2a746d0a4a66 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 3 Oct 2020 14:41:23 +0100 Subject: Objective-C, Darwin : Update protocol metadata to current version. Later versions of the NeXT runtime protocol metadata contain additional fields. This patch adds these fields and populates a new list of method types. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (build_v2_super_template): Add new fields to the template. (build_v2_protocol_template): Build new field entries. (generate_v2_meth_descriptor_table): Adjust to allow recording all method types. (generate_v2_meth_type_list): New. (build_v2_protocol_initializer): Initialize the additional fields. (generate_v2_protocols): Record method types for all entries and generate the additional method type table. --- gcc/objc/objc-next-runtime-abi-02.c | 103 ++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 16 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 5760425..3a30897 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -743,6 +743,9 @@ build_v2_super_template (void) const struct _prop_list_t * const properties; const uint32_t size; const uint32_t flags; + const char ** extended_method_types; + const char * demangled_name; + const struct _prop_list_t * class_properties; } */ static void @@ -784,6 +787,16 @@ build_v2_protocol_template (void) /* const uint32_t flags; */ add_field_decl (integer_type_node, "flags", &chain); + /* const char **extendedMethodTypes; */ + tree ptr_to_ptr_to_char = build_pointer_type (string_type_node); + add_field_decl (ptr_to_ptr_to_char, "extended_method_types", &chain); + + /* const char *demangledName; */ + add_field_decl (string_type_node, "demangled_name", &chain); + + /* const struct _prop_list_t *class_properties; */ + add_field_decl (objc_prop_list_ptr, "class_properties", &chain); + objc_finish_struct (objc_v2_protocol_template, decls); } @@ -2296,9 +2309,10 @@ build_v2_method_list_template (tree list_type, int size) objc_method_prototype_template which is missing this field. */ static tree generate_v2_meth_descriptor_table (tree chain, tree protocol, - const char *prefix, tree attr) + const char *prefix, tree attr, + vec& all_meths) { - tree method_list_template, initlist, decl, methods; + tree method_list_template, initlist, decl; int size, entsize; vec *v = NULL; char buf[BUFSIZE]; @@ -2306,13 +2320,14 @@ generate_v2_meth_descriptor_table (tree chain, tree protocol, if (!chain || !prefix) return NULL_TREE; - methods = chain; + tree method = chain; size = 0; - while (methods) + while (method) { - if (! METHOD_ENCODING (methods)) - METHOD_ENCODING (methods) = encode_method_prototype (methods); - methods = TREE_CHAIN (methods); + if (! METHOD_ENCODING (method)) + METHOD_ENCODING (method) = encode_method_prototype (method); + all_meths.safe_push (method); + method = TREE_CHAIN (method); size++; } @@ -2337,6 +2352,31 @@ generate_v2_meth_descriptor_table (tree chain, tree protocol, return decl; } +static tree +generate_v2_meth_type_list (vec& all_meths, tree protocol, + const char *prefix) +{ + if (all_meths.is_empty () || !prefix) + return NULL_TREE; + + unsigned size = all_meths.length (); + tree list_type = build_sized_array_type (string_type_node, size); + char *nam; + asprintf (&nam, "%s_%s", prefix, + IDENTIFIER_POINTER (PROTOCOL_NAME (protocol))); + tree decl = start_var_decl (list_type, nam); + free (nam); + OBJCMETA (decl, objc_meta, meta_base); + vec *v = NULL; + + for (unsigned i = 0; i < size; ++i) + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, + add_objc_string (METHOD_ENCODING (all_meths[i]), + meth_var_types)); + finish_var_decl (decl, objc_build_constructor (list_type, v)); + return decl; +} + /* This routine builds the initializer list to initialize the 'struct _prop_t prop_list[]' field of 'struct _prop_list_t' meta-data. */ @@ -2463,7 +2503,8 @@ static tree build_v2_protocol_initializer (tree type, tree protocol_name, tree protocol_list, tree inst_methods, tree class_methods, tree opt_ins_meth, tree opt_cls_meth, - tree property_list) + tree property_list, tree ext_meth_types, + tree demangled_name, tree class_prop_list) { tree expr, ttyp; location_t loc; @@ -2518,7 +2559,28 @@ build_v2_protocol_initializer (tree type, tree protocol_name, tree protocol_list /* const uint32_t flags; = 0 */ CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, integer_zero_node); - return objc_build_constructor (type, inits); + ttyp = build_pointer_type (string_type_node); + if (ext_meth_types) + expr = convert (ttyp, build_unary_op (loc, ADDR_EXPR, ext_meth_types, 0)); + else + expr = convert (ttyp, null_pointer_node); + CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr); + + ttyp = string_type_node; + if (demangled_name) + expr = convert (ttyp, build_unary_op (loc, ADDR_EXPR, demangled_name, 0)); + else + expr = convert (ttyp, null_pointer_node); + CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr); + + ttyp = objc_prop_list_ptr; + if (class_prop_list) + expr = convert (ttyp, build_unary_op (loc, ADDR_EXPR, class_prop_list, 0)); + else + expr = convert (ttyp, null_pointer_node); + CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr); + + return objc_build_constructor (type, inits); } /* Main routine to build all meta data for all protocols used in a @@ -2554,25 +2616,26 @@ generate_v2_protocols (void) loc = DECL_SOURCE_LOCATION (decl); some = true; + vec all_meths = vNULL; inst_meth = generate_v2_meth_descriptor_table (PROTOCOL_NST_METHODS (p), p, "_OBJC_ProtocolInstanceMethods", - meta_proto_nst_meth); + meta_proto_nst_meth, all_meths); class_meth = generate_v2_meth_descriptor_table (PROTOCOL_CLS_METHODS (p), p, "_OBJC_ProtocolClassMethods", - meta_proto_cls_meth); + meta_proto_cls_meth, all_meths); opt_inst_meth = generate_v2_meth_descriptor_table (PROTOCOL_OPTIONAL_NST_METHODS (p), p, - "_OBJC_OptProtocolInstMethods", - meta_proto_nst_meth); + "_OBJC_ProtocolOptInstMethods", + meta_proto_nst_meth, all_meths); opt_class_meth = generate_v2_meth_descriptor_table (PROTOCOL_OPTIONAL_CLS_METHODS (p), p, - "_OBJC_OptProtocolClassMethods", - meta_proto_cls_meth); + "_OBJC_ProtocolOptClassMethods", + meta_proto_cls_meth, all_meths); if (PROTOCOL_LIST (p)) refs_decl = generate_v2_protocol_list (p, NULL_TREE); @@ -2590,13 +2653,21 @@ generate_v2_protocols (void) props = generate_v2_property_table (p, NULL_TREE); + tree ext_meth_types + = generate_v2_meth_type_list (all_meths, p, + "_OBJC_ProtocolMethodTypes"); + tree demangled_name = NULL_TREE; + tree class_prop_list = NULL_TREE; + initlist = build_v2_protocol_initializer (TREE_TYPE (decl), protocol_name_expr, refs_expr, inst_meth, class_meth, opt_inst_meth, opt_class_meth, - props); + props, ext_meth_types, + demangled_name,class_prop_list); finish_var_decl (decl, initlist); objc_add_to_protocol_list (p, decl); + all_meths.truncate (0); } if (some) -- cgit v1.1 From 1174b08b140d1fed6012d7dcf66165fabd49b7e5 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 10 Oct 2020 22:21:05 +0100 Subject: Ojective-C, Darwin : Adjust category superclass ref names (NFC). Make the order of the class and superclass match the metadata order from clang. Makes it easier to compare produced meta- data between implementations. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (next_runtime_abi_02_category_decl): Adjust category superclass name ordering. --- gcc/objc/objc-next-runtime-abi-02.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 3a30897..92ede03 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -980,9 +980,9 @@ next_runtime_abi_02_category_decl (tree klass) { tree decl; char buf[BUFSIZE]; - snprintf (buf, BUFSIZE, "_OBJC_Category_%s_on_%s", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (klass)), - IDENTIFIER_POINTER (CLASS_NAME (klass))); + snprintf (buf, BUFSIZE, "_OBJC_Category_%s_%s", + IDENTIFIER_POINTER (CLASS_NAME (klass)), + IDENTIFIER_POINTER (CLASS_SUPER_NAME (klass))); decl = start_var_decl (objc_v2_category_template, buf); OBJCMETA (decl, objc_meta, meta_category); return decl; -- cgit v1.1 From 1cc7476610299eb1969f6a93ee21010ac30f5dd6 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Tue, 6 Oct 2020 18:50:22 +0100 Subject: Objective-C++, Darwin : Make metadata 'extern "C"'. For current system toolchains NeXT runtime metadata symbols are not mangled for Objective-C++ (i.e. they are considered to be 'extern "C"'). This change becomes essential when we start to emit metadata refs as hidden and weak which is required by later editions of the runtime and linkers. gcc/objc/ChangeLog: * objc-runtime-shared-support.c (start_var_decl): Make the decl_assembler_name follow the metadata name for C++ on NeXT runtime platforms. --- gcc/objc/objc-runtime-shared-support.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-runtime-shared-support.c b/gcc/objc/objc-runtime-shared-support.c index 4aecc7f..16d4d63 100644 --- a/gcc/objc/objc-runtime-shared-support.c +++ b/gcc/objc/objc-runtime-shared-support.c @@ -117,14 +117,17 @@ add_field_decl (tree type, const char *name, tree **chain) tree start_var_decl (tree type, const char *name) { - tree var = build_decl (input_location, - VAR_DECL, get_identifier (name), type); - TREE_STATIC (var) = 1; + tree name_id = get_identifier (name); + tree var = build_decl (input_location, VAR_DECL, name_id, type); DECL_INITIAL (var) = error_mark_node; /* A real initializer is coming... */ + TREE_STATIC (var) = 1; DECL_IGNORED_P (var) = 1; DECL_ARTIFICIAL (var) = 1; DECL_CONTEXT (var) = NULL_TREE; #ifdef OBJCPLUS + /* Meta-data for the NeXT runtime is expected to be 'extern "C"'. */ + if (flag_next_runtime) + SET_DECL_ASSEMBLER_NAME (var, name_id); DECL_THIS_STATIC (var) = 1; /* squash redeclaration errors */ #endif return var; -- cgit v1.1 From 3ba0afac60e80851c01541364d8991667809cec0 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Tue, 29 Sep 2020 19:16:12 +0100 Subject: Objective-C, Darwin : Update message call codegen. Platform compilers based on LLVM do not use the objc_sendMsg_fixit and friends for newer editions of the OS (runtimes for Arm64 do not even have those entries). We need to arrange to allow for this codegen on modern Darwin. The _fixit versions are needed for some OS versions (at least, up to 10.6) since the super2 call is not implemented there. It does not seem worth making the codegen more fine-grained at present. Other parts of the codegen need to be made conditional on either the runtime version or the linker capabilities. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (TAG_MSGSENDSUPER): Revised spelling. (TAG_MSGSENDID): Likewise. (TAG_MSGSENDSUPER_STRET): Likewise. (TAG_MSGSENDID_STRET): Likewise. (FIXUP_NEEDED): Likewise. (TAG_FIXUP): New. (next_runtime_02_initialize): Adjust message calls to use fixup variants only when required. (next_runtime_abi_02_get_arg_type_list_base): Correct indent. (build_v2_build_objc_method_call): New. (build_v2_objc_method_fixup_call): Split out from ... (next_runtime_abi_02_build_objc_method_call): ... here. Arrange to adjust the call on the basis of the target runtime. --- gcc/objc/objc-next-runtime-abi-02.c | 233 +++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 46 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 92ede03..0c7a600 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -63,9 +63,15 @@ along with GCC; see the file COPYING3. If not see #define TAG_GETMETACLASS "objc_getMetaClass" #define TAG_MSGSEND "objc_msgSend" -#define TAG_MSGSENDSUPER "objc_msgSendSuper" +#define TAG_MSGSENDID "objc_msgSendId" +#define TAG_MSGSENDSUPER "objc_msgSendSuper2" #define TAG_MSGSEND_STRET "objc_msgSend_stret" -#define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper_stret" +#define TAG_MSGSENDID_STRET "objc_msgSendId_stret" +#define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret" + +#define FIXUP_NEEDED 100600 +#define TAG_FIXUP "_fixup" + #define TAG_NEXT_EHVTABLE_NAME "objc_ehtype_vtable" #define TAG_V2_EH_TYPE "objc_ehtype_t" @@ -386,32 +392,43 @@ static void next_runtime_02_initialize (void) build_v2_protocol_template (); build_v2_category_template (); - /* id objc_msgSend_fixup_rtp (id, struct message_ref_t*, ...); */ - type = build_varargs_function_type_list (objc_object_type, - objc_object_type, - objc_v2_selector_type, - NULL_TREE); - umsg_fixup_decl = add_builtin_function ("objc_msgSend_fixup", - type, 0, NOT_BUILT_IN, + bool fixup_p = flag_next_runtime < FIXUP_NEEDED; + if (fixup_p) + { + /* id objc_msgSend_fixup_rtp (id, struct message_ref_t*, ...); */ + type = build_varargs_function_type_list (objc_object_type, + objc_object_type, + objc_v2_selector_type, + NULL_TREE); + } + else + { + /* id objc_msgSendXXXX (id, SEL, ...); */ + type = build_varargs_function_type_list (objc_object_type, + objc_object_type, + objc_selector_type, + NULL_TREE); + } + const char *fnam = fixup_p ? TAG_MSGSEND TAG_FIXUP : TAG_MSGSEND; + umsg_fixup_decl = add_builtin_function (fnam, type, 0, NOT_BUILT_IN, NULL, NULL_TREE); TREE_NOTHROW (umsg_fixup_decl) = 0; /* id objc_msgSend_stret_fixup_rtp (id, struct message_ref_t*, ...); */ - umsg_stret_fixup_decl = add_builtin_function ("objc_msgSend_stret_fixup", - type, 0, NOT_BUILT_IN, + fnam = fixup_p ? TAG_MSGSEND_STRET TAG_FIXUP : TAG_MSGSEND_STRET; + umsg_stret_fixup_decl = add_builtin_function (fnam, type, 0, NOT_BUILT_IN, NULL, NULL_TREE); TREE_NOTHROW (umsg_stret_fixup_decl) = 0; /* id objc_msgSendId_fixup_rtp (id, struct message_ref_t*, ...); */ - umsg_id_fixup_decl = add_builtin_function ("objc_msgSendId_fixup", - type, 0, NOT_BUILT_IN, + fnam = fixup_p ? TAG_MSGSENDID TAG_FIXUP : TAG_MSGSENDID; + umsg_id_fixup_decl = add_builtin_function (fnam, type, 0, NOT_BUILT_IN, NULL, NULL_TREE); TREE_NOTHROW (umsg_id_fixup_decl) = 0; - /* id objc_msgSendId_stret_fixup_rtp - (id, struct message_ref_t*, ...); */ - umsg_id_stret_fixup_decl = add_builtin_function ("objc_msgSendId_stret_fixup", - type, 0, NOT_BUILT_IN, + /* id objc_msgSendId_stret_fixup_rtp (id, struct message_ref_t*, ...); */ + fnam = fixup_p ? TAG_MSGSENDID_STRET TAG_FIXUP : TAG_MSGSENDID_STRET; + umsg_id_stret_fixup_decl = add_builtin_function (fnam, type, 0, NOT_BUILT_IN, NULL, NULL_TREE); TREE_NOTHROW (umsg_id_stret_fixup_decl) = 0; @@ -421,17 +438,17 @@ static void next_runtime_02_initialize (void) objc_super_type, objc_v2_super_selector_type, NULL_TREE); - umsg_id_super2_fixup_decl = add_builtin_function ("objc_msgSendSuper2_fixup", - type, 0, NOT_BUILT_IN, + fnam = fixup_p ? TAG_MSGSENDSUPER TAG_FIXUP : TAG_MSGSENDSUPER; + umsg_id_super2_fixup_decl = add_builtin_function (fnam, type, 0, NOT_BUILT_IN, NULL, NULL_TREE); TREE_NOTHROW (umsg_id_super2_fixup_decl) = 0; /* id objc_msgSendSuper2_stret_fixup_rtp (struct objc_super *, struct message_ref_t*, ...); */ - umsg_id_super2_stret_fixup_decl = - add_builtin_function ("objc_msgSendSuper2_stret_fixup", - type, 0, NOT_BUILT_IN, - NULL, NULL_TREE); + fnam = fixup_p ? TAG_MSGSENDSUPER_STRET TAG_FIXUP : TAG_MSGSENDSUPER_STRET; + umsg_id_super2_stret_fixup_decl = add_builtin_function (fnam, type, 0, + NOT_BUILT_IN, NULL, + NULL_TREE); TREE_NOTHROW (umsg_id_super2_stret_fixup_decl) = 0; /* Present in the library, but unused by the FE. */ @@ -1134,10 +1151,12 @@ next_runtime_abi_02_get_arg_type_list_base (vec **argtypes, receiver_type = objc_object_type; vec_safe_push (*argtypes, receiver_type); - /* Selector type - will eventually change to `int'. */ - vec_safe_push (*argtypes, - superflag ? objc_v2_super_selector_type - : objc_v2_selector_type); + if (flag_next_runtime < FIXUP_NEEDED) + /* Selector type - will eventually change to `int'. */ + vec_safe_push (*argtypes, superflag ? objc_v2_super_selector_type + : objc_v2_selector_type); + else + vec_safe_push (*argtypes, objc_selector_type); } /* TODO: Merge this with the message refs. */ @@ -1589,10 +1608,9 @@ objc_copy_to_temp_side_effect_params (tree fntype, tree values) (*_msg.messenger) (receiver, &_msg, ...) */ static tree -build_v2_build_objc_method_call (int super_flag, tree method_prototype, - tree lookup_object, tree selector, - tree method_params, - bool check_for_nil) +build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, + tree lookup_object, tree selector, + tree method_params, bool check_for_nil) { tree ret_val; tree sender, rcv_p, t; @@ -1673,6 +1691,118 @@ build_v2_build_objc_method_call (int super_flag, tree method_prototype, } static tree +build_v2_build_objc_method_call (int super, tree method_prototype, + tree lookup_object, tree selector, + tree method_params, location_t loc, + bool check_for_nil, bool rx_is_id) +{ + tree sender, sender_cast, method, t; + tree rcv_p = (super ? objc_super_type : objc_object_type); + vec *parms; + unsigned nparm = (method_params ? list_length (method_params) : 0); + + /* If a prototype for the method to be called exists, then cast + the sender's return type and arguments to match that of the method. + Otherwise, leave sender as is. */ + tree ret_type + = (method_prototype + ? TREE_VALUE (TREE_TYPE (method_prototype)) + : objc_object_type); + tree ftype = build_function_type_for_method (ret_type, method_prototype, + METHOD_REF, super); + + if (method_prototype && METHOD_TYPE_ATTRIBUTES (method_prototype)) + ftype = build_type_attribute_variant (ftype, + METHOD_TYPE_ATTRIBUTES + (method_prototype)); + + sender_cast = build_pointer_type (ftype); + + lookup_object = build_c_cast (loc, rcv_p, lookup_object); + + /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ + lookup_object = save_expr (lookup_object); + + /* Param list + 2 slots for object and selector. */ + vec_alloc (parms, nparm + 2); + + /* If we are returning a struct in memory, and the address + of that memory location is passed as a hidden first + argument, then change which messenger entry point this + expr will call. NB: Note that sender_cast remains + unchanged (it already has a struct return type). */ + if (!targetm.calls.struct_value_rtx (0, 0) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE) + && targetm.calls.return_in_memory (ret_type, 0)) + { + if (super) + sender = umsg_id_super2_stret_fixup_decl; + else + sender = rx_is_id ? umsg_id_stret_fixup_decl + : umsg_stret_fixup_decl; + } + else + { + if (super) + sender = umsg_id_super2_fixup_decl; + else + sender = rx_is_id ? umsg_id_fixup_decl + : umsg_fixup_decl; + } + + method = build_fold_addr_expr_loc (loc, sender); + + /* Pass the object to the method. */ + parms->quick_push (lookup_object); + /* Pass the selector to the method. */ + parms->quick_push (selector); + /* Now append the remainder of the parms. */ + if (nparm) + for (; method_params; method_params = TREE_CHAIN (method_params)) + parms->quick_push (TREE_VALUE (method_params)); + + /* Build an obj_type_ref, with the correct cast for the method call. */ + t = build3 (OBJ_TYPE_REF, sender_cast, method, + lookup_object, size_zero_node); + tree ret_val = build_function_call_vec (loc, vNULL, t, parms, NULL); + vec_free (parms); + if (check_for_nil) + { + /* receiver != nil ? ret_val : 0 */ + tree ftree; + tree ifexp; + + if (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE) + { + vec *rtt = NULL; + /* ??? CHECKME. hmmm..... think we need something more + here. */ + CONSTRUCTOR_APPEND_ELT (rtt, NULL_TREE, NULL_TREE); + ftree = objc_build_constructor (ret_type, rtt); + } + else + ftree = fold_convert (ret_type, integer_zero_node); + + ifexp = build_binary_op (loc, NE_EXPR, + lookup_object, + fold_convert (rcv_p, integer_zero_node), 1); + +#ifdef OBJCPLUS + ret_val = build_conditional_expr (loc, ifexp, ret_val, ftree, + tf_warning_or_error); +#else + /* ??? CHECKME. */ + ret_val = build_conditional_expr (loc, ifexp, 1, + ret_val, NULL_TREE, loc, + ftree, NULL_TREE, loc); +#endif + } + return ret_val; +} + +static tree next_runtime_abi_02_build_objc_method_call (location_t loc, tree method_prototype, tree receiver, @@ -1681,27 +1811,38 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, tree method_params, int super) { - tree ret_type, selector; - tree message_func_decl; - bool check_for_nil = flag_objc_nilcheck; - - ret_type = method_prototype - ? TREE_VALUE (TREE_TYPE (method_prototype)) - : objc_object_type; - /* Do we need to check for nil receivers ? */ /* For now, message sent to classes need no nil check. In the future, class declaration marked as weak_import must be nil checked. */ + bool check_for_nil = flag_objc_nilcheck; if (super || (TREE_CODE (receiver) == VAR_DECL && TREE_TYPE (receiver) == objc_class_type)) check_for_nil = false; + if (flag_next_runtime >= FIXUP_NEEDED) + { + tree selector + = next_runtime_abi_02_build_selector_reference (loc, sel_name, + method_prototype); + return build_v2_build_objc_method_call (super, method_prototype, + receiver, selector, + method_params, loc, + check_for_nil, + objc_is_id (rtype)); + } + + /* else we have to build a pair of the function and selector. */ + tree message_func_decl; + tree ret_type = method_prototype + ? TREE_VALUE (TREE_TYPE (method_prototype)) + : objc_object_type; + if (!targetm.calls.struct_value_rtx (0, 0) - && (TREE_CODE (ret_type) == RECORD_TYPE - || TREE_CODE (ret_type) == UNION_TYPE) - && targetm.calls.return_in_memory (ret_type, 0)) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE) + && targetm.calls.return_in_memory (ret_type, 0)) { if (super) message_func_decl = umsg_id_super2_stret_fixup_decl; @@ -1720,7 +1861,7 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, : umsg_fixup_decl; } - selector = build_v2_selector_messenger_reference (sel_name, + tree selector = build_v2_selector_messenger_reference (sel_name, message_func_decl); /* selector = &_msg; */ @@ -1731,9 +1872,9 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, selector); /* (*_msg.messenger) (receiver, &_msg, ...); */ - return build_v2_build_objc_method_call (super, method_prototype, - receiver, selector, - method_params, check_for_nil); + return build_v2_objc_method_fixup_call (super, method_prototype, receiver, + selector, method_params, + check_for_nil); } /* NOTE --- Constant String Class Stuff --- */ -- cgit v1.1 From 8703bf5d31fdb4789b5eddca394f8e92a0c55801 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sun, 4 Oct 2020 10:09:57 +0100 Subject: Darwin, Objective-C : Adjust objective-c symbol linkage with version. Earlier linkers cannot handle publicly-visible (or linker-visible) metadata, so we need to make the output of these conditional on version. gcc/ChangeLog: * config/darwin.c (darwin_globalize_label): Make a subset of metadate symbols global. (darwin_label_is_anonymous_local_objc_name): Make a subset of metadata symbols linker-visible. (darwin_override_options): Track more target OS versions, make the next_runtime version track this (unless it's set to 0 for GNU runtime). gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (FIXUP_NEEDED): Rename ... (USE_FIXUP_BEFORE): ... to this. (next_runtime_02_initialize): Likewise. (next_runtime_abi_02_get_arg_type_list_base): Likewise. (next_runtime_abi_02_build_objc_method_call): Likewise. --- gcc/objc/objc-next-runtime-abi-02.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 0c7a600..60bf86a 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -69,7 +69,7 @@ along with GCC; see the file COPYING3. If not see #define TAG_MSGSENDID_STRET "objc_msgSendId_stret" #define TAG_MSGSENDSUPER_STRET "objc_msgSendSuper2_stret" -#define FIXUP_NEEDED 100600 +#define USE_FIXUP_BEFORE 100600 #define TAG_FIXUP "_fixup" @@ -392,7 +392,7 @@ static void next_runtime_02_initialize (void) build_v2_protocol_template (); build_v2_category_template (); - bool fixup_p = flag_next_runtime < FIXUP_NEEDED; + bool fixup_p = flag_next_runtime < USE_FIXUP_BEFORE; if (fixup_p) { /* id objc_msgSend_fixup_rtp (id, struct message_ref_t*, ...); */ @@ -1151,7 +1151,7 @@ next_runtime_abi_02_get_arg_type_list_base (vec **argtypes, receiver_type = objc_object_type; vec_safe_push (*argtypes, receiver_type); - if (flag_next_runtime < FIXUP_NEEDED) + if (flag_next_runtime < USE_FIXUP_BEFORE) /* Selector type - will eventually change to `int'. */ vec_safe_push (*argtypes, superflag ? objc_v2_super_selector_type : objc_v2_selector_type); @@ -1821,7 +1821,7 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, && TREE_TYPE (receiver) == objc_class_type)) check_for_nil = false; - if (flag_next_runtime >= FIXUP_NEEDED) + if (flag_next_runtime >= USE_FIXUP_BEFORE) { tree selector = next_runtime_abi_02_build_selector_reference (loc, sel_name, -- cgit v1.1 From 73699d921d8734c351b9897f16a04453f6a47301 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 10 Oct 2020 11:14:47 +0100 Subject: Objective-C++ : Fix bitfield ivars. This fixes a regression present from 8.x; It used to be OK to test for a DECL_INITIAL value to flag that an ivar was a bitfield (the initial value was the width). This still works on C / Objective-C, but no longer on C++. Replace the test with DECL_C_BIT_FIELD() which is set for both C and C++. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref): Test DECL_C_BIT_FIELD to detect that an ivar is a bitfield. --- gcc/objc/objc-next-runtime-abi-02.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 60bf86a..b83c9a3 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1395,12 +1395,7 @@ objc_v2_build_ivar_ref (tree datum, tree component) return NULL_TREE; /* This routine only handles non-bitfield fields */ - /* DECL_INITIAL macro is set to width of bitfield and can be relied - on to check for bitfield ivars. Note that I cannot rely on - DECL_BIT_FIELD macro because it is only set when the whole struct - is seen (at finish_struct) and not when the ivar chain is - built. */ - if (DECL_INITIAL (field)) + if (DECL_C_BIT_FIELD (field)) return NULL_TREE; create_ivar_offset_name (var_offset_name, CLASS_NAME (class_name), field); -- cgit v1.1 From 07c7498dc0379354d73ef4c8fd92d0473eb3a12f Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 3 Oct 2020 20:49:53 +0100 Subject: Objective-C, Darwin : Make protocols private extern and weak. Newer linkers want protocols to be private-extern and weak. This is conditional on the runtime version. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (create_global_decl): Update to allow the caller to specify declaration or definition. (create_hidden_decl): Likewise. (next_runtime_abi_02_protocol_decl): Make the symbol weak and hidden for later OS runtime versions. (build_v2_protocol_list_address_table): Likewise. --- gcc/objc/objc-next-runtime-abi-02.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index b83c9a3..d7812ff 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -920,33 +920,39 @@ create_extern_decl (tree type, const char *name) /* Create a globally visible definition for variable NAME of a given TYPE. The finish_var_decl() routine will need to be called on it afterwards. */ +static tree +create_global_decl (tree type, const char *name, bool is_def = false); static tree -create_global_decl (tree type, const char *name) +create_global_decl (tree type, const char *name, bool is_def) { tree id = get_identifier (name); tree var = hash_name_lookup (extern_names, id); if (var) - { - DECL_EXTERNAL (var) = 0; - TREE_STATIC (var) = 1; - } + is_def = true; else { var = start_var_decl (type, name); hash_name_enter (extern_names, var); } + if (is_def) + { + DECL_EXTERNAL (var) = 0; + TREE_STATIC (var) = 1; + } TREE_PUBLIC (var) = 1; return var; } /* Create a symbol with __attribute__ ((visibility ("hidden"))) attribute (private extern). */ +static tree +create_hidden_decl (tree type, const char *name, bool is_def = false); static tree -create_hidden_decl (tree type, const char *name) +create_hidden_decl (tree type, const char *name, bool is_def) { - tree decl = create_global_decl (type, name); + tree decl = create_global_decl (type, name, is_def); DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; DECL_VISIBILITY_SPECIFIED (decl) = 1; return decl; @@ -1014,7 +1020,13 @@ next_runtime_abi_02_protocol_decl (tree p) /* static struct _objc_protocol _OBJC_Protocol_; */ snprintf (buf, BUFSIZE, "_OBJC_Protocol_%s", IDENTIFIER_POINTER (PROTOCOL_NAME (p))); - decl = start_var_decl (objc_v2_protocol_template, buf); + if (flag_next_runtime >= USE_FIXUP_BEFORE) + { + decl = create_hidden_decl (objc_v2_protocol_template, buf); + DECL_WEAK (decl) = true; + } + else + decl = start_var_decl (objc_v2_protocol_template, buf); OBJCMETA (decl, objc_meta, meta_protocol); return decl; } @@ -2295,7 +2307,13 @@ build_v2_protocol_list_address_table (void) gcc_assert (ref->id && TREE_CODE (ref->id) == PROTOCOL_INTERFACE_TYPE); snprintf (buf, BUFSIZE, "_OBJC_LabelProtocol_%s", IDENTIFIER_POINTER (PROTOCOL_NAME (ref->id))); - decl = create_global_decl (objc_protocol_type, buf); + if (flag_next_runtime >= USE_FIXUP_BEFORE) + { + decl = create_hidden_decl (objc_protocol_type, buf, /*is def=*/true); + DECL_WEAK (decl) = true; + } + else + decl = create_global_decl (objc_protocol_type, buf, /*is def=*/true); expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl)); OBJCMETA (decl, objc_meta, meta_label_protocollist); finish_var_decl (decl, expr); -- cgit v1.1 From 2baa36d4911940a068e63f2ee4298c13f92cf8d9 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 12 Oct 2020 00:16:25 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 065dba6..f69d2d7 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,69 @@ +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c + (create_global_decl): Update to allow the caller to + specify declaration or definition. + (create_hidden_decl): Likewise. + (next_runtime_abi_02_protocol_decl): Make the symbol + weak and hidden for later OS runtime versions. + (build_v2_protocol_list_address_table): Likewise. + +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref): Test + DECL_C_BIT_FIELD to detect that an ivar is a bitfield. + +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c (FIXUP_NEEDED): Rename ... + (USE_FIXUP_BEFORE): ... to this. + (next_runtime_02_initialize): Likewise. + (next_runtime_abi_02_get_arg_type_list_base): Likewise. + (next_runtime_abi_02_build_objc_method_call): Likewise. + +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c (TAG_MSGSENDSUPER): Revised + spelling. + (TAG_MSGSENDID): Likewise. + (TAG_MSGSENDSUPER_STRET): Likewise. + (TAG_MSGSENDID_STRET): Likewise. + (FIXUP_NEEDED): Likewise. + (TAG_FIXUP): New. + (next_runtime_02_initialize): Adjust message calls to use + fixup variants only when required. + (next_runtime_abi_02_get_arg_type_list_base): Correct + indent. + (build_v2_build_objc_method_call): New. + (build_v2_objc_method_fixup_call): Split out from ... + (next_runtime_abi_02_build_objc_method_call): ... here. + Arrange to adjust the call on the basis of the target + runtime. + +2020-10-11 Iain Sandoe + + * objc-runtime-shared-support.c (start_var_decl): Make the + decl_assembler_name follow the metadata name for C++ on NeXT + runtime platforms. + +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c + (next_runtime_abi_02_category_decl): Adjust category + superclass name ordering. + +2020-10-11 Iain Sandoe + + * objc-next-runtime-abi-02.c (build_v2_super_template): Add new + fields to the template. + (build_v2_protocol_template): Build new field entries. + (generate_v2_meth_descriptor_table): Adjust to allow recording all + method types. + (generate_v2_meth_type_list): New. + (build_v2_protocol_initializer): Initialize the additional fields. + (generate_v2_protocols): Record method types for all entries and + generate the additional method type table. + 2020-10-10 Iain Sandoe * objc-next-runtime-abi-02.c -- cgit v1.1