diff mbox series

[11/13] v2 Use new per-location warning APIs in the Objective-C front end

Message ID 969d1ed9-5a7e-5e30-dae0-ac0937bdfaa6@gmail.com
State New
Headers show
Series v2 warning control by group and location (PR 74765) | expand

Commit Message

Martin Sebor June 4, 2021, 9:43 p.m. UTC
The attached patch replaces the uses of TREE_NO_WARNING in
the Objective-C front end with the new suppress_warning(),
warning_suppressed_p(), and copy_warning() APIs.

Comments

Jeff Law June 24, 2021, 5:02 a.m. UTC | #1
On 6/4/2021 3:43 PM, Martin Sebor via Gcc-patches wrote:
> The attached patch replaces the uses of TREE_NO_WARNING in
> the Objective-C front end with the new suppress_warning(),
> warning_suppressed_p(), and copy_warning() APIs.
>
> gcc-no-warning-objc.diff
>
> 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.
OK once prereqs are approved.

Jeff
Martin Sebor June 28, 2021, 9:22 p.m. UTC | #2
On 6/23/21 11:02 PM, Jeff Law wrote:
> 
> 
> On 6/4/2021 3:43 PM, Martin Sebor via Gcc-patches wrote:
>> The attached patch replaces the uses of TREE_NO_WARNING in
>> the Objective-C front end with the new suppress_warning(),
>> warning_suppressed_p(), and copy_warning() APIs.
>>
>> gcc-no-warning-objc.diff
>>
>> 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.
> OK once prereqs are approved.
> 
> Jeff

Retested and pushed in r12-1860.

Martin
diff mbox series

Patch

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.

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 8d106a4de26..ec20891152b 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 4add71edf41..976fa1e36cb 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 3ec6e1703c1..183fc01abb2 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 3cfcd0b1a57..963d1bf1ad8 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*, ...)