From 6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 17 Mar 2021 16:36:44 +0100 Subject: Come up with startswith function. gcc/ada/ChangeLog: * gcc-interface/utils.c (def_builtin_1): Use startswith function instead of strncmp. gcc/analyzer/ChangeLog: * sm-file.cc (is_file_using_fn_p): Use startswith function instead of strncmp. gcc/ChangeLog: * builtins.c (is_builtin_name): Use startswith function instead of strncmp. * collect2.c (main): Likewise. (has_lto_section): Likewise. (scan_libraries): Likewise. * coverage.c (coverage_checksum_string): Likewise. (coverage_init): Likewise. * dwarf2out.c (is_cxx): Likewise. (gen_compile_unit_die): Likewise. * gcc-ar.c (main): Likewise. * gcc.c (init_spec): Likewise. (read_specs): Likewise. (execute): Likewise. (check_live_switch): Likewise. * genattrtab.c (write_attr_case): Likewise. (IS_ATTR_GROUP): Likewise. * gencfn-macros.c (main): Likewise. * gengtype.c (type_for_name): Likewise. (gen_rtx_next): Likewise. (get_file_langdir): Likewise. (write_local): Likewise. * genmatch.c (get_operator): Likewise. (get_operand_type): Likewise. (expr::gen_transform): Likewise. * genoutput.c (validate_optab_operands): Likewise. * incpath.c (add_sysroot_to_chain): Likewise. * langhooks.c (lang_GNU_C): Likewise. (lang_GNU_CXX): Likewise. (lang_GNU_Fortran): Likewise. (lang_GNU_OBJC): Likewise. * lto-wrapper.c (run_gcc): Likewise. * omp-general.c (omp_max_simt_vf): Likewise. * omp-low.c (omp_runtime_api_call): Likewise. * opts-common.c (parse_options_from_collect_gcc_options): Likewise. * read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise. * real.c (real_from_string): Likewise. * selftest.c (assert_str_startswith): Likewise. * timevar.c (timer::validate_phases): Likewise. * tree.c (get_file_function_name): Likewise. * ubsan.c (ubsan_use_new_style_p): Likewise. * varasm.c (default_function_rodata_section): Likewise. (incorporeal_function_p): Likewise. (default_section_type_flags): Likewise. * system.h (startswith): Define startswith. gcc/c-family/ChangeLog: * c-ada-spec.c (print_destructor): Use startswith function instead of strncmp. (dump_ada_declaration): Likewise. * c-common.c (disable_builtin_function): Likewise. (def_builtin_1): Likewise. * c-format.c (check_tokens): Likewise. (check_plain): Likewise. (convert_format_name_to_system_name): Likewise. gcc/c/ChangeLog: * c-aux-info.c (affix_data_type): Use startswith function instead of strncmp. * c-typeck.c (build_function_call_vec): Likewise. * gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Use startswith function instead of strncmp. (cxx_builtin_function): Likewise. (omp_declare_variant_finalize_one): Likewise. (grokfndecl): Likewise. * error.c (dump_decl_name): Likewise. * mangle.c (find_decomp_unqualified_name): Likewise. (write_guarded_var_name): Likewise. (decl_tls_wrapper_p): Likewise. * parser.c (cp_parser_simple_type_specifier): Likewise. (cp_parser_tx_qualifier_opt): Likewise. * pt.c (template_parm_object_p): Likewise. (dguide_name_p): Likewise. gcc/d/ChangeLog: * d-builtins.cc (do_build_builtin_fn): Use startswith function instead of strncmp. * dmd/dinterpret.c (evaluateIfBuiltin): Likewise. * dmd/dmangle.c: Likewise. * dmd/hdrgen.c: Likewise. * dmd/identifier.c (Identifier::toHChars2): Likewise. gcc/fortran/ChangeLog: * decl.c (variable_decl): Use startswith function instead of strncmp. (gfc_match_end): Likewise. * gfortran.h (gfc_str_startswith): Likewise. * module.c (load_omp_udrs): Likewise. (read_module): Likewise. * options.c (gfc_handle_runtime_check_option): Likewise. * primary.c (match_arg_list_function): Likewise. * trans-decl.c (gfc_get_symbol_decl): Likewise. * trans-expr.c (gfc_conv_procedure_call): Likewise. * trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise. gcc/go/ChangeLog: * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith function instead of strncmp. gcc/objc/ChangeLog: * objc-act.c (objc_string_ref_type_p): Use startswith function instead of strncmp. * objc-encoding.c (encode_type): Likewise. * objc-next-runtime-abi-02.c (has_load_impl): Likewise. --- gcc/objc/objc-act.c | 2 +- gcc/objc/objc-encoding.c | 2 +- gcc/objc/objc-next-runtime-abi-02.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 1cbd586..796256d 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -10275,7 +10275,7 @@ objc_string_ref_type_p (tree strp) return (tmv && TREE_CODE (tmv) == IDENTIFIER_NODE && IDENTIFIER_POINTER (tmv) - && !strncmp (IDENTIFIER_POINTER (tmv), "NSString", 8)); + && startswith (IDENTIFIER_POINTER (tmv), "NSString")); } /* At present the behavior of this is undefined and it does nothing. */ diff --git a/gcc/objc/objc-encoding.c b/gcc/objc/objc-encoding.c index c4067b1..7ad920a 100644 --- a/gcc/objc/objc-encoding.c +++ b/gcc/objc/objc-encoding.c @@ -733,7 +733,7 @@ encode_type (tree type, int curtype, int format) char *enc = (char *) obstack_base (&util_obstack) + curtype; /* Rewrite "in const" from "nr" to "rn". */ - if (curtype >= 1 && !strncmp (enc - 1, "nr", 2)) + if (curtype >= 1 && startswith (enc - 1, "nr")) memcpy (enc - 1, "rn", 2); } } diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index af68c1c..3cfcd0b 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -2209,7 +2209,7 @@ has_load_impl (tree clsmeth) { tree id = METHOD_SEL_NAME (clsmeth); if (IDENTIFIER_LENGTH (id) == 4 - && strncmp (IDENTIFIER_POINTER (id), "load", 4) == 0) + && startswith (IDENTIFIER_POINTER (id), "load")) return true; clsmeth = DECL_CHAIN (clsmeth); } -- cgit v1.1 From aa891c56f25baac94db004e309d1b6e40b770a95 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 11 May 2021 00:16:36 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 6bb584c..9474135 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,10 @@ +2021-05-10 Martin Liska + + * objc-act.c (objc_string_ref_type_p): Use startswith + function instead of strncmp. + * objc-encoding.c (encode_type): Likewise. + * objc-next-runtime-abi-02.c (has_load_impl): Likewise. + 2020-11-20 Jakub Jelinek PR other/97911 -- cgit v1.1 From 459d84e9b6e925922246b6aff76a5202b1d4d4ba Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Fri, 30 Apr 2021 07:52:40 -0700 Subject: opts: change write_symbols to support bitmasks To support multiple debug formats, we need to move away from explicit enumeration of each individual combination of debug formats. gcc/c-family/ChangeLog: * c-opts.c (c_common_post_options): Adjust access to debug_type_names. * c-pch.c (struct c_pch_validity): Use type uint32_t. (pch_init): Renamed member. (c_common_valid_pch): Adjust access to debug_type_names. gcc/ChangeLog: * common.opt: Change type to support bitmasks. * flag-types.h (enum debug_info_type): Rename enumerator constants. (NO_DEBUG): New bitmask. (DBX_DEBUG): Likewise. (DWARF2_DEBUG): Likewise. (XCOFF_DEBUG): Likewise. (VMS_DEBUG): Likewise. (VMS_AND_DWARF2_DEBUG): Likewise. * flags.h (debug_set_to_format): New function declaration. (debug_set_count): Likewise. (debug_set_names): Likewise. * opts.c (debug_type_masks): Array of bitmasks for debug formats. (debug_set_to_format): New function definition. (debug_set_count): Likewise. (debug_set_names): Likewise. (set_debug_level): Update access to debug_type_names. * toplev.c: Likewise. gcc/objc/ChangeLog: * objc-act.c (synth_module_prologue): Use uint32_t instead of enum debug_info_type. gcc/testsuite/ChangeLog: * gcc.dg/pch/valid-1.c: Adjust diagnostic message in testcase. * lib/dg-pch.exp: Adjust diagnostic message. --- gcc/objc/objc-act.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 796256d..8d106a4 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -3078,7 +3078,7 @@ static void synth_module_prologue (void) { tree type; - enum debug_info_type save_write_symbols = write_symbols; + uint32_t save_write_symbols = write_symbols; const struct gcc_debug_hooks *const save_hooks = debug_hooks; /* Suppress outputting debug symbols, because -- cgit v1.1 From ea34e2edd3d7ab245d1f57a1487c10587f324ec6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 21 May 2021 00:16:57 +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 9474135..7ae02af 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2021-05-20 Indu Bhagat + + * objc-act.c (synth_module_prologue): Use uint32_t instead of enum + debug_info_type. + 2021-05-10 Martin Liska * objc-act.c (objc_string_ref_type_p): Use startswith -- cgit v1.1 From 3e00f8ddb729913831e494f87207b658292e6c2b Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Fri, 28 May 2021 06:54:13 +0200 Subject: For obj-c stage-final re-use the checksum from the previous stage This silences the stage compare. gcc/objc: 2021-06-07 Bernd Edlinger * Make-lang.in (cc1obj-checksum.c): For stage-final re-use the checksum from the previous stage. gcc/objcp: 2021-06-07 Bernd Edlinger * Make-lang.in (cc1objplus-checksum.c): For stage-final re-use the checksum from the previous stage. --- gcc/objc/Make-lang.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index c91148a..9011140 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -57,11 +57,19 @@ OBJC_OBJS = objc/objc-lang.o objc/objc-act.o hash-table.o \ objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o +# compute checksum over all object files and the options +# re-use the checksum from the prev-final stage so it passes +# the bootstrap comparison and allows comparing of the cc1 binary cc1obj-checksum.c : build/genchecksum$(build_exeext) checksum-options \ $(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS) - build/genchecksum$(build_exeext) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \ - $(BACKEND) $(LIBDEPS) checksum-options > cc1obj-checksum.c.tmp && \ - $(srcdir)/../move-if-change cc1obj-checksum.c.tmp cc1obj-checksum.c + if [ -f ../stage_final ] \ + && cmp -s ../stage_current ../stage_final; then \ + cp ../prev-gcc/$@ $@; \ + else \ + build/genchecksum$(build_exeext) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \ + $(BACKEND) $(LIBDEPS) checksum-options > $@.tmp && \ + $(srcdir)/../move-if-change $@.tmp $@; \ + fi cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) \ $(LIBDEPS) $(objc.prev) -- cgit v1.1 From 438aac594e1c5ad32b787e8753b3893044ecf26f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 8 Jun 2021 00:16:44 +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 7ae02af..6a3d66e 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2021-06-07 Bernd Edlinger + + * Make-lang.in (cc1obj-checksum.c): For stage-final re-use + the checksum from the previous stage. + 2021-05-20 Indu Bhagat * objc-act.c (synth_module_prologue): Use uint32_t instead of enum -- cgit v1.1 From 40917137b6bb66c8020add0b4083c13b566275ba Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Tue, 8 Jun 2021 22:14:52 +0200 Subject: Fix bootstrap2 breakage due to re-use of obj-c checksum gcc/objc: 2021-06-08 Bernd Edlinger * Make-lang.in (cc1-obj-checksum.c): Check previous stage checksum exists. gcc/objcp: 2021-06-08 Bernd Edlinger * Make-lang.in (cc1objplus-checksum.c): Check previous stage checksum exists. --- gcc/objc/Make-lang.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/objc') diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 9011140..8215283 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -63,7 +63,8 @@ objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o cc1obj-checksum.c : build/genchecksum$(build_exeext) checksum-options \ $(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS) if [ -f ../stage_final ] \ - && cmp -s ../stage_current ../stage_final; then \ + && cmp -s ../stage_current ../stage_final \ + && [ -f ../prev-gcc/$@ ]; then \ cp ../prev-gcc/$@ $@; \ else \ build/genchecksum$(build_exeext) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \ -- cgit v1.1 From c60387214593445d1514bf7852f27f4523458cda Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 9 Jun 2021 00:16:30 +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 6a3d66e..693146d 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2021-06-08 Bernd Edlinger + + * Make-lang.in (cc1-obj-checksum.c): Check previous + stage checksum exists. + 2021-06-07 Bernd Edlinger * Make-lang.in (cc1obj-checksum.c): For stage-final re-use -- cgit v1.1 From 6ed359cd8b37a9a85cb6e93d9f40736d8f559495 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 9 Jun 2021 12:59:52 +0200 Subject: Fix my e-mail in the ChangeLog --- gcc/objc/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 693146d..2c8acae 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -3,7 +3,7 @@ * Make-lang.in (cc1-obj-checksum.c): Check previous stage checksum exists. -2021-06-07 Bernd Edlinger +2021-06-07 Bernd Edlinger * Make-lang.in (cc1obj-checksum.c): For stage-final re-use the checksum from the previous stage. -- cgit v1.1 From ed94172c7e174a9b56b9de066f4fb7e71c9ebaf9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 28 Jun 2021 15:13:17 -0600 Subject: objc: Add support for per-location warning groups. gcc/objc/ChangeLog: * objc-act.c (objc_maybe_build_modify_expr): Replace direct uses of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning. (objc_build_incr_expr_for_property_ref): Same. (objc_build_struct): Same. (synth_module_prologue): Same. * objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Same. * objc-next-runtime-abi-01.c (next_runtime_01_initialize): Same. * objc-next-runtime-abi-02.c (next_runtime_02_initialize): Same. --- gcc/objc/objc-act.c | 15 ++++++++------- gcc/objc/objc-gnu-runtime-abi-01.c | 2 +- gcc/objc/objc-next-runtime-abi-01.c | 2 +- gcc/objc/objc-next-runtime-abi-02.c | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 8d106a4..ec20891 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2007,7 +2007,7 @@ objc_maybe_build_modify_expr (tree lhs, tree rhs) correct (maybe a more sophisticated implementation could avoid generating the compound expression if not needed), but we need to turn it off. */ - TREE_NO_WARNING (compound_expr) = 1; + suppress_warning (compound_expr, OPT_Wunused); return compound_expr; } else @@ -2129,7 +2129,7 @@ objc_build_incr_expr_for_property_ref (location_t location, /* Prevent C++ from warning with -Wall that "right operand of comma operator has no effect". */ - TREE_NO_WARNING (compound_expr) = 1; + suppress_warning (compound_expr, OPT_Wunused); return compound_expr; } @@ -2262,8 +2262,9 @@ objc_build_struct (tree klass, tree fields, tree super_name) DECL_FIELD_IS_BASE (base) = 1; if (fields) - TREE_NO_WARNING (fields) = 1; /* Suppress C++ ABI warnings -- we */ -#endif /* are following the ObjC ABI here. */ + /* Suppress C++ ABI warnings: we are following the ObjC ABI here. */ + suppress_warning (fields, OPT_Wabi); +#endif DECL_CHAIN (base) = fields; fields = base; } @@ -3112,19 +3113,19 @@ synth_module_prologue (void) TYPE_DECL, objc_object_name, objc_object_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, objc_instancetype_name, objc_instancetype_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, objc_class_name, objc_class_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); /* Forward-declare '@interface Protocol'. */ type = get_identifier (PROTOCOL_OBJECT_CLASS_NAME); diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index 4add71e..976fa1e 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -213,7 +213,7 @@ static void gnu_runtime_01_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); /* typedef id (*IMP)(id, SEL, ...); */ ftype = build_varargs_function_type_list (objc_object_type, diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 3ec6e17..183fc01 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -282,7 +282,7 @@ static void next_runtime_01_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); build_v1_class_template (); build_super_template (); diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 3cfcd0b..963d1bf 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -379,7 +379,7 @@ static void next_runtime_02_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + suppress_warning (type); /* IMP : id (*) (id, _message_ref_t*, ...) SUPER_IMP : id (*) ( super_t*, _super_message_ref_t*, ...) -- cgit v1.1 From c8abc2058e96dd12454078d66be9982dfebfd154 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 29 Jun 2021 00:16:42 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 2c8acae..bb84045 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,14 @@ +2021-06-28 Martin Sebor + + * objc-act.c (objc_maybe_build_modify_expr): Replace direct uses + of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning. + (objc_build_incr_expr_for_property_ref): Same. + (objc_build_struct): Same. + (synth_module_prologue): Same. + * objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Same. + * objc-next-runtime-abi-01.c (next_runtime_01_initialize): Same. + * objc-next-runtime-abi-02.c (next_runtime_02_initialize): Same. + 2021-06-08 Bernd Edlinger * Make-lang.in (cc1-obj-checksum.c): Check previous -- cgit v1.1 From 798666392b512a585f0de2983a5d3423e960959e Mon Sep 17 00:00:00 2001 From: Matt Jacobson Date: Thu, 29 Jul 2021 09:57:23 +0100 Subject: Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2. Signed-off-by: Matt Jacobson gcc/c-family/ChangeLog: * c-opts.c (c_common_post_options): Default to flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Warn about and reset flag_objc_sjlj_exceptions regardless of flag_objc_exceptions. (next_runtime_02_initialize): Use a checking assert that flag_objc_sjlj_exceptions is off. --- 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 963d1bf..c552013 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -245,7 +245,7 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks) { extern_names = ggc_cleared_vec_alloc (SIZEHASHTABLE); - if (flag_objc_exceptions && flag_objc_sjlj_exceptions) + if (flag_objc_sjlj_exceptions) { inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for " @@ -507,7 +507,7 @@ static void next_runtime_02_initialize (void) objc_getPropertyStruct_decl = NULL_TREE; objc_setPropertyStruct_decl = NULL_TREE; - gcc_assert (!flag_objc_sjlj_exceptions); + gcc_checking_assert (!flag_objc_sjlj_exceptions); /* Although we warn that fobjc-exceptions is required for exceptions code, we carry on and create it anyway. */ -- cgit v1.1 From 2d14d64bf2d42a87ec58dd3760be12aeaa4a4279 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 18 Aug 2021 00:16:48 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index bb84045..8adde0d 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,11 @@ +2021-08-17 Matt Jacobson + + * objc-next-runtime-abi-02.c + (objc_next_runtime_abi_02_init): Warn about and reset + flag_objc_sjlj_exceptions regardless of flag_objc_exceptions. + (next_runtime_02_initialize): Use a checking assert that + flag_objc_sjlj_exceptions is off. + 2021-06-28 Martin Sebor * objc-act.c (objc_maybe_build_modify_expr): Replace direct uses -- cgit v1.1 From d2aa4e0b3b5053df8f5853d9ed29022ff0d3ecf6 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 14 Aug 2021 12:27:55 +0100 Subject: Objective-C: fix crash with -fobjc-nilcheck When -fobjc-nilcheck is enabled, messages that result in a struct type should yield a zero-initialized struct when sent to nil. Currently, the frontend crashes when it encounters this situation. This patch fixes the crash by generating the tree for the `{}` initializer. Signed-off-by: Iain Sandoe Co-authored-by: Matt Jacobson PR objc/101666 gcc/objc/ChangeLog: * objc-act.c (objc_build_constructor): Handle empty constructor lists. * objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call): Handle nil receivers. (build_v2_build_objc_method_call): Likewise. gcc/testsuite/ChangeLog: * obj-c++.dg/pr101666-0.mm: New test. * obj-c++.dg/pr101666-1.mm: New test. * obj-c++.dg/pr101666.inc: New. * objc.dg/pr101666-0.m: New test. * objc.dg/pr101666-1.m: New test. * objc.dg/pr101666.inc: New. --- gcc/objc/objc-act.c | 16 +++++++++------- gcc/objc/objc-next-runtime-abi-02.c | 22 +++++++--------------- 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index ec20891..6e4fb62 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -3377,8 +3377,10 @@ objc_build_string_object (tree string) return addr; } -/* Build a static constant CONSTRUCTOR - with type TYPE and elements ELTS. */ +/* Build a static constant CONSTRUCTOR with type TYPE and elements ELTS. + We might be presented with a NULL for ELTS, which means 'empty ctor' + which will subsequently be converted into a zero initializer in the + middle end. */ tree objc_build_constructor (tree type, vec *elts) @@ -3390,12 +3392,10 @@ objc_build_constructor (tree type, vec *elts) TREE_READONLY (constructor) = 1; #ifdef OBJCPLUS - /* Adjust for impedance mismatch. We should figure out how to build - CONSTRUCTORs that consistently please both the C and C++ gods. */ - if (!(*elts)[0].index) + /* If we know the initializer, then set the type to what C++ expects. */ + if (elts && !(*elts)[0].index) TREE_TYPE (constructor) = init_list_type_node; #endif - return constructor; } @@ -9664,7 +9664,9 @@ objc_gimplify_property_ref (tree *expr_p) call_exp = TREE_OPERAND (getter, 1); } #endif - gcc_assert (TREE_CODE (call_exp) == CALL_EXPR); + gcc_checking_assert ((flag_objc_nilcheck + && TREE_CODE (call_exp) == COND_EXPR) + || TREE_CODE (call_exp) == CALL_EXPR); *expr_p = call_exp; } diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index c552013..0d963e3 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1675,13 +1675,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, 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); - } + /* An empty constructor is zero-filled by the middle end. */ + ftree = objc_build_constructor (ret_type, NULL); else ftree = fold_convert (ret_type, integer_zero_node); @@ -1694,11 +1689,11 @@ build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, ifexp, ret_val, ftree, tf_warning_or_error); #else - /* ??? CHECKME. */ ret_val = build_conditional_expr (input_location, - ifexp, 1, + ifexp, 0, ret_val, NULL_TREE, input_location, ftree, NULL_TREE, input_location); + ret_val = fold_convert (ret_type, ret_val); #endif } return ret_val; @@ -1790,11 +1785,8 @@ build_v2_build_objc_method_call (int super, tree method_prototype, 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); + /* An empty constructor is zero-filled by the middle end. */ + ftree = objc_build_constructor (ret_type, NULL); } else ftree = fold_convert (ret_type, integer_zero_node); @@ -1807,10 +1799,10 @@ build_v2_build_objc_method_call (int super, tree method_prototype, 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); + ret_val = fold_convert (ret_type, ret_val); #endif } return ret_val; -- cgit v1.1 From 6e529985d8956f74492e3176026fc02dc8f01b6c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 19 Aug 2021 00:16:42 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 8adde0d..ea8c88b 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,13 @@ +2021-08-18 Iain Sandoe + Matt Jacobson + + PR objc/101666 + * objc-act.c (objc_build_constructor): Handle empty constructor + lists. + * objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call): + Handle nil receivers. + (build_v2_build_objc_method_call): Likewise. + 2021-08-17 Matt Jacobson * objc-next-runtime-abi-02.c -- cgit v1.1 From de0b250b2badb475f8c09f3cd2c57fd3f9127fe3 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sun, 15 Aug 2021 12:52:30 +0100 Subject: Objective-C, NeXT runtime: Correct the default for fobjc-nilcheck. It is intended that the default for the NeXT runtime at ABI 2 is to check for nil message receivers. This updates this to match the documented behaviour and to match the behaviour of the system tools. Signed-off-by: Iain Sandoe gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Default receiver nilchecks on. --- gcc/objc/objc-next-runtime-abi-02.c | 4 ++++ 1 file changed, 4 insertions(+) (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 0d963e3..ce831fc 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -254,6 +254,10 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks) flag_objc_sjlj_exceptions = 0; } + /* NeXT ABI 2 is intended to default to checking for nil receivers. */ + if (! global_options_set.x_flag_objc_nilcheck) + flag_objc_nilcheck = 1; + rthooks->initialize = next_runtime_02_initialize; rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME; rthooks->tag_getclass = TAG_GETCLASS; -- cgit v1.1 From b57fba5e376c7277168c14e207979e1505e6fe1d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 20 Aug 2021 00:16:28 +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 ea8c88b..e2d452f 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2021-08-19 Iain Sandoe + + * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): + Default receiver nilchecks on. + 2021-08-18 Iain Sandoe Matt Jacobson -- cgit v1.1 From 8433baadec88e5f31fa141b6d78094e91256079d Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sun, 8 Nov 2020 09:04:07 +0000 Subject: C-family: Add attribute 'unavailable'. If an interface is marked 'deprecated' then, presumably, at some point it will be withdrawn and no longer available. The 'unavailable' attribute makes it possible to mark up interfaces to indicate this status. It is used quite extensively in some codebases where a single set of headers can be used to permit code generation for multiple system versions. From a configuration perspective, it also allows a compile test to determine that an interface is missing - rather than requiring a link test. The implementation follows the pattern of attribute deprecated, but produces an error (where deprecation produces a warning). This attribute has been implemented in clang for some years. Signed-off-by: Iain Sandoe gcc/c-family/ChangeLog: * c-attribs.c (handle_unavailable_attribute): New. gcc/c/ChangeLog: * c-decl.c (enum deprecated_states): Add unavailable state. (merge_decls): Copy unavailability. (quals_from_declspecs): Handle unavailable case. (start_decl): Amend the logic handling suppression of nested deprecation states to include unavailability. (smallest_type_quals_location): Amend comment. (grokdeclarator): Handle the unavailable deprecation state. (declspecs_add_type): Set TREE_UNAVAILABLE from the decl specs. * c-tree.h (struct c_declspecs): Add unavailable_p. * c-typeck.c (build_component_ref): Handle unavailability. (build_external_ref): Likewise. gcc/cp/ChangeLog: * call.c (build_over_call): Handle unavailable state in addition to deprecation. * class.c (type_build_ctor_call): Likewise. (type_build_dtor_call): Likewise. * cp-tree.h: Rename cp_warn_deprecated_use to cp_handle_deprecated_or_unavailable. * decl.c (duplicate_decls): Merge unavailability. (grokdeclarator): Handle unavailability in addition to deprecation. (type_is_unavailable): New. (grokparms): Handle unavailability in addition to deprecation. * decl.h (enum deprecated_states): Add UNAVAILABLE_DEPRECATED_SUPPRESS. * decl2.c (cplus_decl_attributes): Propagate unavailability to templates. (cp_warn_deprecated_use): Rename to ... (cp_handle_deprecated_or_unavailable): ... this and amend to handle the unavailable case. It remains a warning in the case of deprecation but becomes an error in the case of unavailability. (cp_warn_deprecated_use_scopes): Handle unavailability. (mark_used): Likewise. * parser.c (cp_parser_template_name): Likewise. (cp_parser_template_argument): Likewise. (cp_parser_parameter_declaration_list): Likewise. * typeck.c (build_class_member_access_expr): Likewise. (finish_class_member_access_expr): Likewise. * typeck2.c (build_functional_cast_1): Likewise. gcc/ChangeLog: * doc/extend.texi: Document unavailable attribute. * print-tree.c (print_node): Handle unavailable attribute. * tree-core.h (struct tree_base): Add a bit to carry unavailability. * tree.c (error_unavailable_use): New. * tree.h (TREE_UNAVAILABLE): New. (error_unavailable_use): New. gcc/objc/ChangeLog: * objc-act.c (objc_add_property_declaration): Register unavailable attribute. (maybe_make_artificial_property_decl): Set available. (objc_maybe_build_component_ref): Generalise to the method prototype to count availability. (objc_build_class_component_ref): Likewise. (build_private_template): Likewise. (objc_decl_method_attributes): Handle unavailable attribute. (lookup_method_in_hash_lists): Amend comments. (objc_finish_message_expr): Handle unavailability in addition to deprecation. (start_class): Likewise. (finish_class): Likewise. (lookup_protocol): Likewise. (objc_declare_protocol): Likewise. (start_protocol): Register unavailable attribute. (really_start_method): Likewise. (objc_gimplify_property_ref): Emit error on encountering an unavailable entity (and a warning for a deprecated one). gcc/testsuite/ChangeLog: * g++.dg/ext/attr-unavailable-1.C: New test. * g++.dg/ext/attr-unavailable-2.C: New test. * g++.dg/ext/attr-unavailable-3.C: New test. * g++.dg/ext/attr-unavailable-4.C: New test. * g++.dg/ext/attr-unavailable-5.C: New test. * g++.dg/ext/attr-unavailable-6.C: New test. * g++.dg/ext/attr-unavailable-7.C: New test. * g++.dg/ext/attr-unavailable-8.C: New test. * g++.dg/ext/attr-unavailable-9.C: New test. * gcc.dg/attr-unavailable-1.c: New test. * gcc.dg/attr-unavailable-2.c: New test. * gcc.dg/attr-unavailable-3.c: New test. * gcc.dg/attr-unavailable-4.c: New test. * gcc.dg/attr-unavailable-5.c: New test. * gcc.dg/attr-unavailable-6.c: New test. * obj-c++.dg/attributes/method-unavailable-1.mm: New test. * obj-c++.dg/attributes/method-unavailable-2.mm: New test. * obj-c++.dg/attributes/method-unavailable-3.mm: New test. * obj-c++.dg/property/at-property-unavailable-1.mm: New test. * obj-c++.dg/property/at-property-unavailable-2.mm: New test. * obj-c++.dg/property/dotsyntax-unavailable-1.mm: New test. * objc.dg/attributes/method-unavailable-1.m: New test. * objc.dg/attributes/method-unavailable-2.m: New test. * objc.dg/attributes/method-unavailable-3.m: New test. * objc.dg/property/at-property-unavailable-1.m: New test. * objc.dg/property/at-property-unavailable-2.m: New test. * objc.dg/property/dotsyntax-unavailable-1.m: New test. --- gcc/objc/objc-act.c | 81 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 20 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 6e4fb62..9baa46d 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1302,6 +1302,7 @@ objc_add_property_declaration (location_t location, tree decl, TREE_TYPE (property_decl) = p_type; DECL_SOURCE_LOCATION (property_decl) = DECL_SOURCE_LOCATION (decl); TREE_DEPRECATED (property_decl) = TREE_DEPRECATED (decl); + TREE_UNAVAILABLE (property_decl) = TREE_UNAVAILABLE (decl); /* Add property-specific information. */ PROPERTY_NAME (property_decl) = DECL_NAME (decl); @@ -1439,6 +1440,7 @@ maybe_make_artificial_property_decl (tree interface, tree implementation, TREE_TYPE (property_decl) = type; DECL_SOURCE_LOCATION (property_decl) = input_location; TREE_DEPRECATED (property_decl) = 0; + TREE_UNAVAILABLE (property_decl) = 0; DECL_ARTIFICIAL (property_decl) = 1; /* Add property-specific information. Note that one of @@ -1717,7 +1719,7 @@ objc_maybe_build_component_ref (tree object, tree property_ident) { tree expression; tree getter_call; - tree deprecated_method_prototype = NULL_TREE; + tree method_prototype_avail = NULL_TREE; /* We have an additional nasty problem here; if this PROPERTY_REF needs to become a 'getter', then the conversion @@ -1751,10 +1753,10 @@ objc_maybe_build_component_ref (tree object, tree property_ident) is deprecated, but record the fact that the getter is deprecated by setting PROPERTY_REF_DEPRECATED_GETTER to the method prototype. */ - &deprecated_method_prototype); + &method_prototype_avail); expression = build4 (PROPERTY_REF, TREE_TYPE(x), object, x, getter_call, - deprecated_method_prototype); + method_prototype_avail); SET_EXPR_LOCATION (expression, input_location); TREE_SIDE_EFFECTS (expression) = 1; @@ -1804,7 +1806,9 @@ objc_build_class_component_ref (tree class_name, tree property_ident) } else { - if (TREE_DEPRECATED (rtype)) + if (TREE_UNAVAILABLE (rtype)) + error ("class %qE is unavailable", class_name); + else if (TREE_DEPRECATED (rtype)) warning (OPT_Wdeprecated_declarations, "class %qE is deprecated", class_name); } @@ -1816,17 +1820,17 @@ objc_build_class_component_ref (tree class_name, tree property_ident) { tree expression; tree getter_call; - tree deprecated_method_prototype = NULL_TREE; + tree method_prototype_avail = NULL_TREE; if (PROPERTY_HAS_NO_GETTER (x)) getter_call = NULL_TREE; else getter_call = objc_finish_message_expr (object, PROPERTY_GETTER_NAME (x), NULL_TREE, - &deprecated_method_prototype); + &method_prototype_avail); expression = build4 (PROPERTY_REF, TREE_TYPE(x), object, x, getter_call, - deprecated_method_prototype); + method_prototype_avail); SET_EXPR_LOCATION (expression, input_location); TREE_SIDE_EFFECTS (expression) = 1; @@ -4598,6 +4602,8 @@ build_private_template (tree klass) /* Copy the attributes from the class to the type. */ if (TREE_DEPRECATED (klass)) TREE_DEPRECATED (record) = 1; + if (TREE_UNAVAILABLE (klass)) + TREE_UNAVAILABLE (record) = 1; } } @@ -5023,6 +5029,7 @@ objc_decl_method_attributes (tree *node, tree attributes, int flags) tree name = TREE_PURPOSE (attribute); if (is_attribute_p ("deprecated", name) + || is_attribute_p ("unavailable", name) || is_attribute_p ("sentinel", name) || is_attribute_p ("noreturn", name)) { @@ -5488,9 +5495,9 @@ lookup_method_in_hash_lists (tree sel_name, int is_class) C++ template functions, it is called from 'build_expr_from_tree' (in decl2.c) after RECEIVER and METHOD_PARAMS have been expanded. - If the DEPRECATED_METHOD_PROTOTYPE argument is NULL, then we warn + If the method_prototype_avail argument is NULL, then we warn if the method being used is deprecated. If it is not NULL, instead - of deprecating, we set *DEPRECATED_METHOD_PROTOTYPE to the method + of deprecating, we set *method_prototype_avail to the method prototype that was used and is deprecated. This is useful for getter calls that are always generated when compiling dot-syntax expressions, even if they may not be used. In that case, we don't @@ -5499,7 +5506,7 @@ lookup_method_in_hash_lists (tree sel_name, int is_class) used. */ tree objc_finish_message_expr (tree receiver, tree sel_name, tree method_params, - tree *deprecated_method_prototype) + tree *method_prototype_avail) { tree method_prototype = NULL_TREE, rprotos = NULL_TREE, rtype; tree retval, class_tree; @@ -5811,10 +5818,17 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params, In practice this makes sense since casting an object to 'id' is often used precisely to turn off warnings associated with the object being of a particular class. */ - if (TREE_DEPRECATED (method_prototype) && rtype != NULL_TREE) + if (TREE_UNAVAILABLE (method_prototype) && rtype != NULL_TREE) { - if (deprecated_method_prototype) - *deprecated_method_prototype = method_prototype; + if (method_prototype_avail) + *method_prototype_avail = method_prototype; + else + error_unavailable_use (method_prototype, NULL_TREE); + } + else if (TREE_DEPRECATED (method_prototype) && rtype != NULL_TREE) + { + if (method_prototype_avail) + *method_prototype_avail = method_prototype; else warn_deprecated_use (method_prototype, NULL_TREE); } @@ -6986,7 +7000,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, } else { - if (TREE_DEPRECATED (super_interface)) + if (TREE_UNAVAILABLE (super_interface)) + error ("class %qE is not available", super); + else if (TREE_DEPRECATED (super_interface)) warning (OPT_Wdeprecated_declarations, "class %qE is deprecated", super); super_name = super; @@ -7096,7 +7112,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, /* TODO: Document what the objc_exception attribute is/does. */ /* We handle the 'deprecated', 'visibility' and (undocumented) 'objc_exception' attributes. */ - if (is_attribute_p ("deprecated", name)) + if (is_attribute_p ("unavailable", name)) + TREE_UNAVAILABLE (klass) = 1; + else if (is_attribute_p ("deprecated", name)) TREE_DEPRECATED (klass) = 1; else if (is_attribute_p ("objc_exception", name)) CLASS_HAS_EXCEPTION_ATTR (klass) = 1; @@ -7127,7 +7145,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, } else { - if (TREE_DEPRECATED (class_category_is_assoc_with)) + if (TREE_UNAVAILABLE (class_category_is_assoc_with)) + error ("class %qE is unavailable", class_name); + else if (TREE_DEPRECATED (class_category_is_assoc_with)) warning (OPT_Wdeprecated_declarations, "class %qE is deprecated", class_name); @@ -8154,6 +8174,7 @@ finish_class (tree klass) else objc_add_method (objc_interface_context, getter_decl, false, false); TREE_DEPRECATED (getter_decl) = TREE_DEPRECATED (x); + TREE_UNAVAILABLE (getter_decl) = TREE_UNAVAILABLE (x); METHOD_PROPERTY_CONTEXT (getter_decl) = x; } @@ -8198,6 +8219,7 @@ finish_class (tree klass) else objc_add_method (objc_interface_context, setter_decl, false, false); TREE_DEPRECATED (setter_decl) = TREE_DEPRECATED (x); + TREE_UNAVAILABLE (setter_decl) = TREE_UNAVAILABLE (x); METHOD_PROPERTY_CONTEXT (setter_decl) = x; } } @@ -8251,7 +8273,9 @@ lookup_protocol (tree ident, bool warn_if_deprecated, bool definition_required) for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain)) if (ident == PROTOCOL_NAME (chain)) { - if (warn_if_deprecated && TREE_DEPRECATED (chain)) + if (TREE_UNAVAILABLE (chain)) + error ("protocol %qE is unavailable", PROTOCOL_NAME (chain)); + else if (warn_if_deprecated && TREE_DEPRECATED (chain)) { /* It would be nice to use warn_deprecated_use() here, but we are using TREE_CHAIN (which is supposed to be the @@ -8276,6 +8300,7 @@ void objc_declare_protocol (tree name, tree attributes) { bool deprecated = false; + bool unavailable = false; #ifdef OBJCPLUS if (current_namespace != global_namespace) { @@ -8294,6 +8319,8 @@ objc_declare_protocol (tree name, tree attributes) if (is_attribute_p ("deprecated", name)) deprecated = true; + else if (is_attribute_p ("unavailable", name)) + unavailable = true; else warning (OPT_Wattributes, "%qE attribute directive ignored", name); } @@ -8318,6 +8345,8 @@ objc_declare_protocol (tree name, tree attributes) TYPE_ATTRIBUTES (protocol) = attributes; if (deprecated) TREE_DEPRECATED (protocol) = 1; + if (unavailable) + TREE_UNAVAILABLE (protocol) = 1; } } } @@ -8327,6 +8356,7 @@ start_protocol (enum tree_code code, tree name, tree list, tree attributes) { tree protocol; bool deprecated = false; + bool unavailable = false; #ifdef OBJCPLUS if (current_namespace != global_namespace) { @@ -8345,6 +8375,8 @@ start_protocol (enum tree_code code, tree name, tree list, tree attributes) if (is_attribute_p ("deprecated", name)) deprecated = true; + else if (is_attribute_p ("unavailable", name)) + unavailable = true; else warning (OPT_Wattributes, "%qE attribute directive ignored", name); } @@ -8384,6 +8416,8 @@ start_protocol (enum tree_code code, tree name, tree list, tree attributes) TYPE_ATTRIBUTES (protocol) = attributes; if (deprecated) TREE_DEPRECATED (protocol) = 1; + if (unavailable) + TREE_UNAVAILABLE (protocol) = 1; } return protocol; @@ -8913,6 +8947,8 @@ really_start_method (tree method, warnings are produced), but just in case. */ if (TREE_DEPRECATED (proto)) TREE_DEPRECATED (method) = 1; + if (TREE_UNAVAILABLE (proto)) + TREE_UNAVAILABLE (method) = 1; /* If the method in the @interface was marked as 'noreturn', mark the function implementing the method @@ -9644,12 +9680,17 @@ objc_gimplify_property_ref (tree *expr_p) return; } + /* FIXME, this should be a label indicating availability in general. */ if (PROPERTY_REF_DEPRECATED_GETTER (*expr_p)) { - /* PROPERTY_REF_DEPRECATED_GETTER contains the method prototype + if (TREE_UNAVAILABLE (PROPERTY_REF_DEPRECATED_GETTER (*expr_p))) + error_unavailable_use (PROPERTY_REF_DEPRECATED_GETTER (*expr_p), + NULL_TREE); + else + /* PROPERTY_REF_DEPRECATED_GETTER contains the method prototype that is deprecated. */ - warn_deprecated_use (PROPERTY_REF_DEPRECATED_GETTER (*expr_p), - NULL_TREE); + warn_deprecated_use (PROPERTY_REF_DEPRECATED_GETTER (*expr_p), + NULL_TREE); } call_exp = getter; -- cgit v1.1 From 1cef3039b880a21fbdf4153e6fc42026619fd4ad Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Mon, 16 Aug 2021 21:22:13 +0100 Subject: Objective-C, NeXT: Fix messenging non-aggregate return-in-memory. When a method returns a type that the platform ABI says should be returned in memory, and that is done by a hidden 'sret' parameter, the message send calls must be adjusted to inform the runtime that the sret parameter is present. As reported in the PR, this is not working for non-aggregate types that use this mechanism. The fix here is to adjust the logic such that all return values that flag 'in memory' are considered to use the mechanism *unless* they provide a struct_value_rtx *and* the return object is an aggregate. Signed-off-by: Iain Sandoe PR objc/101718 - Objective-C frontend emits wrong code to call methods returning scalar types returned in memory PR objc/101718 gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (build_v2_build_objc_method_call): Revise for cases where scalar objects use an sret parameter. (next_runtime_abi_02_build_objc_method_call): Likwise. --- gcc/objc/objc-next-runtime-abi-02.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 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 ce831fc..9c35738 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1739,15 +1739,16 @@ build_v2_build_objc_method_call (int super, tree method_prototype, /* 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 we are returning an item that must be returned in memory, and the + target ABI does this by an invisible pointer provided as the first arg, + we need to adjust the message signature to include this. The second + part of this excludes targets that provide some alternate scheme for + structure returns. */ + if (ret_type && !VOID_TYPE_P (ret_type) + && targetm.calls.return_in_memory (ret_type, 0) + && !(targetm.calls.struct_value_rtx (0, 0) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE))) { if (super) sender = umsg_id_super2_stret_fixup_decl; @@ -1849,10 +1850,12 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, ? 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)) + /* See comment for the fixup version above. */ + if (ret_type && !VOID_TYPE_P (ret_type) + && targetm.calls.return_in_memory (ret_type, 0) + && !(targetm.calls.struct_value_rtx (0, 0) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE))) { if (super) message_func_decl = umsg_id_super2_stret_fixup_decl; -- cgit v1.1 From e11c6046f9c8bc891a67f37f0260ef4ece482f5d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 2 Sep 2021 00:16:59 +0000 Subject: Daily bump. --- gcc/objc/ChangeLog | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e2d452f..668be66 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,32 @@ +2021-09-01 Iain Sandoe + + PR objc/101718 + * objc-next-runtime-abi-02.c (build_v2_build_objc_method_call): + Revise for cases where scalar objects use an sret parameter. + (next_runtime_abi_02_build_objc_method_call): Likwise. + +2021-09-01 Iain Sandoe + + * objc-act.c (objc_add_property_declaration): Register unavailable + attribute. + (maybe_make_artificial_property_decl): Set available. + (objc_maybe_build_component_ref): Generalise to the method prototype + to count availability. + (objc_build_class_component_ref): Likewise. + (build_private_template): Likewise. + (objc_decl_method_attributes): Handle unavailable attribute. + (lookup_method_in_hash_lists): Amend comments. + (objc_finish_message_expr): Handle unavailability in addition to + deprecation. + (start_class): Likewise. + (finish_class): Likewise. + (lookup_protocol): Likewise. + (objc_declare_protocol): Likewise. + (start_protocol): Register unavailable attribute. + (really_start_method): Likewise. + (objc_gimplify_property_ref): Emit error on encountering an + unavailable entity (and a warning for a deprecated one). + 2021-08-19 Iain Sandoe * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): -- cgit v1.1