diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-10-13 08:16:42 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-10-13 08:16:42 +0000 |
commit | 5254c66ba0c8f9f45c3054cc41131141ff81330c (patch) | |
tree | 90a905402a30b7ee4f28d659a1e3f13ab50b2d19 | |
parent | b4ca4f9e328cbce0f3aa9b13931900b2e5bd752e (diff) | |
download | gcc-5254c66ba0c8f9f45c3054cc41131141ff81330c.zip gcc-5254c66ba0c8f9f45c3054cc41131141ff81330c.tar.gz gcc-5254c66ba0c8f9f45c3054cc41131141ff81330c.tar.bz2 |
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
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/pr23214.m | 27 | ||||
-rw-r--r-- | libobjc/ChangeLog | 8 | ||||
-rw-r--r-- | libobjc/init.c | 36 |
4 files changed, 58 insertions, 18 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 72f281c..0c0803e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..946dbeb --- /dev/null +++ b/gcc/testsuite/objc.dg/pr23214.m @@ -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 diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 7e21bf5..29edebd 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,13 @@ 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 objc_get_uninstalled_dtable, objc_object_alloc.h and struct_objc_static_instances.h. diff --git a/libobjc/init.c b/libobjc/init.c index 0f714c4..8712257 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) |