From ed94172c7e174a9b56b9de066f4fb7e71c9ebaf9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 28 Jun 2021 15:13:17 -0600 Subject: [PATCH] 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(-) 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*, ...) -- 2.7.4