summaryrefslogtreecommitdiff
path: root/libobjc/init.c
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-10-13 08:16:42 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-10-13 08:16:42 +0000
commit5254c66ba0c8f9f45c3054cc41131141ff81330c (patch)
tree90a905402a30b7ee4f28d659a1e3f13ab50b2d19 /libobjc/init.c
parentb4ca4f9e328cbce0f3aa9b13931900b2e5bd752e (diff)
In libobjc/: 2010-10-13 Nicola Pero <nicola.pero@meta-innovation.com>
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
Diffstat (limited to 'libobjc/init.c')
-rw-r--r--libobjc/init.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/libobjc/init.c b/libobjc/init.c
index 0f714c40596..87122577829 100644
--- a/libobjc/init.c
+++ b/libobjc/init.c
@@ -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)