]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
In libobjc/: 2010-10-13 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola.pero@meta-innovation.com>
Wed, 13 Oct 2010 08:16:42 +0000 (08:16 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Wed, 13 Oct 2010 08:16:42 +0000 (08:16 +0000)
In libobjc/:
2010-10-13  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR libobjc/23214
        * init.c (objc_init_statics): Do not skip the initialization of a
        statics list if the first object has already been initialized; in
        the case of Protocols, while the first one may have been
        initialized, some others may not have been initialized yet.

In gcc/testsuite/:
2010-10-13  Nicola Pero  <nicola.pero@meta-innovation.com>

        PR libobjc/23214
        * objc.dg/pr23214.m: New.

From-SVN: r165414

gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/pr23214.m [new file with mode: 0644]
libobjc/ChangeLog
libobjc/init.c

index 72f281c0eaaab2932722901c3613fa0d059d6153..0c0803ee0e511a7810eb5e5cfe6f6638fdc7527b 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-13  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR libobjc/23214
+       * objc.dg/pr23214.m: New.
+
 2010-10-12  Michael Eager  <eager@eagercon.com>
 
        PR testsuite/45856
diff --git a/gcc/testsuite/objc.dg/pr23214.m b/gcc/testsuite/objc.dg/pr23214.m
new file mode 100644 (file)
index 0000000..946dbeb
--- /dev/null
@@ -0,0 +1,27 @@
+/* Test that there is no problem initializing multiple static
+   Protocol instances.  */
+
+/* { dg-do run } */
+
+#include <objc/Object.h>
+#include <objc/Protocol.h>
+
+@protocol A
+@end
+
+@protocol B 
+@end
+
+@interface Dummy : Object <B>
+@end
+
+int main ()
+{
+  [@protocol(A) class];
+  [@protocol(B) class];
+
+  return 0;
+}
+
+@implementation Dummy
+@end
index 7e21bf5da76cfa240910df8a2285c78b957f61fd..29edebd4ca172e3ed0968e101b7fa5da47312065 100644 (file)
@@ -1,3 +1,11 @@
+2010-10-13  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR libobjc/23214
+       * init.c (objc_init_statics): Do not skip the initialization of a
+       statics list if the first object has already been initialized; in
+       the case of Protocols, while the first one may have been
+       initialized, some others may not have been initialized yet.
+
 2010-10-13  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * Makefile.in (OBJC_DEPRECATED_H): Added
index 0f714c4059661f35f2e57d9e593eec54f6f2c18d..87122577829b3ac63e919fd8cd5043c31846b0d5 100644 (file)
@@ -473,28 +473,28 @@ objc_init_statics (void)
          Class class = objc_lookup_class (statics->class_name);
 
          if (! class)
-           module_initialized = 0;
-         /* Actually, the static's class_pointer will be NULL when we
-             haven't been here before.  However, the comparison is to be
-             reminded of taking into account class posing and to think about
-             possible semantics...  */
-         else if (class != statics->instances[0]->class_pointer)
            {
+             /* It is unfortunate that this will cause all the
+                statics initialization to be done again (eg, if we
+                already initialized constant strings, and are now
+                initializing protocols, setting module_initialized to
+                0 would cause constant strings to be initialized
+                again).  It would be good to be able to track if we
+                have already initialized some of them.  */
+             module_initialized = 0;
+           }
+         else
+           {
+             /* Note that if this is a list of Protocol objects, some
+                of them may have been initialized already (because
+                they were attached to classes or categories, and the
+                class/category loading code automatically fixes them
+                up), and some of them may not.  We really need to go
+                through the whole list to be sure!  */
              id *inst;
 
              for (inst = &statics->instances[0]; *inst; inst++)
-               {
-                 (*inst)->class_pointer = class;
-
-                 /* ??? Make sure the object will not be freed.  With
-                     refcounting, invoke `-retain'.  Without refcounting, do
-                     nothing and hope that `-free' will never be invoked.  */
-
-                 /* ??? Send the object an `-initStatic' or something to
-                     that effect now or later on?  What are the semantics of
-                     statically allocated instances, besides the trivial
-                     NXConstantString, anyway?  */
-               }
+               (*inst)->class_pointer = class;
            }
        }
       if (module_initialized)