This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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" } */
+
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]