fix _OBJC_Module defined but not used warning
diff mbox

Message ID 55742CFB.2060209@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez June 7, 2015, 11:37 a.m. UTC
On 06/07/2015 06:19 AM, Andreas Schwab wrote:
> Another fallout:
>
> FAIL: obj-c++.dg/try-catch-5.mm -fgnu-runtime (test for excess errors)
> Excess errors:
> <built-in>: warning: '_OBJC_Module' defined but not used [-Wunused-variable]

check_global_declarations is called for more symbols now.  All the 
defined but not used errors I've seen in development have been 
legitimate.  For tests, the tests should be fixed.  For built-ins such 
as these, does the attached fix the problem?

It is up to the objc maintainers, we can either fix this with the 
attached patch, or setting DECL_IN_SYSTEM_HEADER.

/* Nonzero for a given ..._DECL node means that no warnings should be
    generated just because this node is unused.  */
#define DECL_IN_SYSTEM_HEADER(NODE) \
   (in_system_header_at (DECL_SOURCE_LOCATION (NODE)))

Let me know what you prefer.
Aldy
commit 25ce72372f7b1309004b87810140573b422e1355
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sun Jun 7 07:32:12 2015 -0400

    	* objc-runtime-shared-support.c (build_module_descriptor): Set
    	TREE_USED on UOBJC_MODULES_decl.

Comments

Andreas Schwab June 7, 2015, 1:08 p.m. UTC | #1
Aldy Hernandez <aldyh@redhat.com> writes:

> check_global_declarations is called for more symbols now.  All the defined
> but not used errors I've seen in development have been legitimate.  For
> tests, the tests should be fixed.  For built-ins such as these, does the
> attached fix the problem?

Yes, it does.

Andreas.
Iain Sandoe June 8, 2015, 8:03 a.m. UTC | #2
Hi Aldy,

On 7 Jun 2015, at 12:37, Aldy Hernandez wrote:

> On 06/07/2015 06:19 AM, Andreas Schwab wrote:
>> Another fallout:
>> 
>> FAIL: obj-c++.dg/try-catch-5.mm -fgnu-runtime (test for excess errors)
>> Excess errors:
>> <built-in>: warning: '_OBJC_Module' defined but not used [-Wunused-variable]
> 
> check_global_declarations is called for more symbols now.  All the defined but not used errors I've seen in development have been legitimate.  For tests, the tests should be fixed.  For built-ins such as these, does the attached fix the problem?
> 
> It is up to the objc maintainers, we can either fix this with the attached patch,

The current patch is OK.

> or setting DECL_IN_SYSTEM_HEADER.

This seems a better long-term idea; however, I would prefer to go through all the cases where it would be applicable (including for the NeXT runtime) and apply that change as a coherent patch.  At the moment dealing with the NeXT stuff is a bit hampered by pr66448.

thanks,
Iain
Aldy Hernandez June 8, 2015, 10:23 a.m. UTC | #3
On 06/08/2015 04:03 AM, Iain Sandoe wrote:
> Hi Aldy,
>
> On 7 Jun 2015, at 12:37, Aldy Hernandez wrote:
>
>> On 06/07/2015 06:19 AM, Andreas Schwab wrote:
>>> Another fallout:
>>>
>>> FAIL: obj-c++.dg/try-catch-5.mm -fgnu-runtime (test for excess errors)
>>> Excess errors:
>>> <built-in>: warning: '_OBJC_Module' defined but not used [-Wunused-variable]
>>
>> check_global_declarations is called for more symbols now.  All the defined but not used errors I've seen in development have been legitimate.  For tests, the tests should be fixed.  For built-ins such as these, does the attached fix the problem?
>>
>> It is up to the objc maintainers, we can either fix this with the attached patch,
>
> The current patch is OK.

Committed.

>
>> or setting DECL_IN_SYSTEM_HEADER.
>
> This seems a better long-term idea; however, I would prefer to go through all the cases where it would be applicable (including for the NeXT runtime) and apply that change as a coherent patch.  At the moment dealing with the NeXT stuff is a bit hampered by pr66448.

On my list next.

Aldy

Patch
diff mbox

diff --git a/gcc/objc/objc-runtime-shared-support.c b/gcc/objc/objc-runtime-shared-support.c
index d9b3c27..1bcb14a 100644
--- a/gcc/objc/objc-runtime-shared-support.c
+++ b/gcc/objc/objc-runtime-shared-support.c
@@ -519,6 +519,9 @@  build_module_descriptor (long vers, tree attr)
      is referenced by the runtime and, therefore, needed.  */
   DECL_PRESERVE_P (UOBJC_MODULES_decl) = 1;
 
+  /* Squash `defined but not used' warning.  */
+  TREE_USED (UOBJC_MODULES_decl) = 1;
+
   /* Allow the runtime to mark meta-data such that it can be assigned to target
      specific sections by the back-end.  */
   if (attr)