This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[objc/PATCH] Fix PR 27438, warning about an ARTIFICIAL decl not being used
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Jan 2007 20:59:56 -0800
- Subject: [objc/PATCH] Fix PR 27438, warning about an ARTIFICIAL decl not being used
Hi,
The problem here is that the _OBJC_INSTANCE_* decl are not marked as
used until after the warning had already been emitted (while in
unit-at-a-time). This patch just marks the decl as being used so we
don't get the warning for this decl.
OK for trunk, 4.2, and 4.1? Bootstrapped and tested on i686-linux-gnu
with no regressions.
Thanks,
Andrew Pinski
* objc-act.c (objc_add_static_instance): Mark the decl as
TREE_USED.
* objc.dg/const-str-12.m: New test.
Index: objc/objc-act.c
===================================================================
--- objc/objc-act.c (revision 121047)
+++ objc/objc-act.c (working copy)
@@ -2007,6 +2007,7 @@ objc_add_static_instance (tree construct
DECL_COMMON (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
+ TREE_USED (decl) = 1;
DECL_INITIAL (decl) = constructor;
/* We may be writing something else just now.
Index: testsuite/objc.dg/const-str-12.m
===================================================================
--- testsuite/objc.dg/const-str-12.m (revision 0)
+++ testsuite/objc.dg/const-str-12.m (revision 0)
@@ -0,0 +1,15 @@
+/* { dg-options "-Wall -funit-at-a-time -fgnu-runtime" } */
+/* { dg-do compile } */
+/* PR objc/27438, make sure that the decl produced by the front-end
+ does not cause a warning to be produced. */
+
+@interface NXConstantString
+{
+ void *isa;
+ const char * const nxcsptr;
+ const unsigned int nxcslen;
+}
+@end
+NXConstantString *a = @"NSInconsistentArchiveException"; /* { dg-bogus "defined but not used" } */
+
+