mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 19:03:59 +08:00
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
This commit is contained in:
parent
b4ca4f9e32
commit
5254c66ba0
@ -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
|
||||
|
27
gcc/testsuite/objc.dg/pr23214.m
Normal file
27
gcc/testsuite/objc.dg/pr23214.m
Normal file
@ -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
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user