mirror of git://gcc.gnu.org/git/gcc.git
In libobjc/: 2011-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/: 2011-02-28 Nicola Pero <nicola.pero@meta-innovation.com> * selector.c (sel_getTypedSelector): Return NULL if there are multiple selectors with conflicting types. * objc/runtime.h (sel_getTypedSelector): Updated documentation. In gcc/testsuite/: 2011-02-28 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/gnu-api-2-sel.m: Test that sel_getTypedSelector return NULL in case of a selector with conflicting types. * obj-c++.dg/gnu-api-2-sel.mm: Same change. From-SVN: r170563
This commit is contained in:
parent
2f2935b6d5
commit
68ade9e4e8
|
@ -1,3 +1,9 @@
|
||||||
|
2011-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
|
* objc.dg/gnu-api-2-sel.m: Test that sel_getTypedSelector return
|
||||||
|
NULL in case of a selector with conflicting types.
|
||||||
|
* obj-c++.dg/gnu-api-2-sel.mm: Same change.
|
||||||
|
|
||||||
2011-02-28 Kazu Hirata <kazu@codesourcery.com>
|
2011-02-28 Kazu Hirata <kazu@codesourcery.com>
|
||||||
|
|
||||||
* gcc.target/arm/vfp-ldmdbd.c, gcc.target/arm/vfp-ldmdbs.c,
|
* gcc.target/arm/vfp-ldmdbd.c, gcc.target/arm/vfp-ldmdbs.c,
|
||||||
|
|
|
@ -46,6 +46,21 @@
|
||||||
- (void) method { return; }
|
- (void) method { return; }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface ClassA : MyRootClass
|
||||||
|
- (id) conflictingSelectorMethod;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassA
|
||||||
|
- (id) conflictingSelectorMethod { return nil; }
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface ClassB : MyRootClass
|
||||||
|
- (void) conflictingSelectorMethod;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassB
|
||||||
|
- (void) conflictingSelectorMethod { return; }
|
||||||
|
@end
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
|
@ -132,6 +147,13 @@ int main ()
|
||||||
untyped. */
|
untyped. */
|
||||||
selector = sel_getTypedSelector ("registered_with_no_types");
|
selector = sel_getTypedSelector ("registered_with_no_types");
|
||||||
|
|
||||||
|
if (selector != NULL)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
/* Now try a selector with multiple, conflicting types. NULL
|
||||||
|
should be returned. */
|
||||||
|
selector = sel_getTypedSelector ("conflictingSelectorMethod");
|
||||||
|
|
||||||
if (selector != NULL)
|
if (selector != NULL)
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,21 @@
|
||||||
- (void) method { return; }
|
- (void) method { return; }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface ClassA : MyRootClass
|
||||||
|
- (id) conflictingSelectorMethod;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassA
|
||||||
|
- (id) conflictingSelectorMethod { return nil; }
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface ClassB : MyRootClass
|
||||||
|
- (void) conflictingSelectorMethod;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassB
|
||||||
|
- (void) conflictingSelectorMethod { return; }
|
||||||
|
@end
|
||||||
|
|
||||||
int main(int argc, void **args)
|
int main(int argc, void **args)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +147,13 @@ int main(int argc, void **args)
|
||||||
untyped. */
|
untyped. */
|
||||||
selector = sel_getTypedSelector ("registered_with_no_types");
|
selector = sel_getTypedSelector ("registered_with_no_types");
|
||||||
|
|
||||||
|
if (selector != NULL)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
/* Now try a selector with multiple, conflicting types. NULL
|
||||||
|
should be returned. */
|
||||||
|
selector = sel_getTypedSelector ("conflictingSelectorMethod");
|
||||||
|
|
||||||
if (selector != NULL)
|
if (selector != NULL)
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2011-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
|
* selector.c (sel_getTypedSelector): Return NULL if there are
|
||||||
|
multiple selectors with conflicting types.
|
||||||
|
* objc/runtime.h (sel_getTypedSelector): Updated documentation.
|
||||||
|
|
||||||
2011-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
2011-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
PR libobjc/47922
|
PR libobjc/47922
|
||||||
|
|
|
@ -226,14 +226,16 @@ objc_EXPORT SEL * sel_copyTypedSelectorList (const char *name,
|
||||||
unsigned int *numberOfReturnedSelectors);
|
unsigned int *numberOfReturnedSelectors);
|
||||||
|
|
||||||
/* Return a selector with name 'name' and a non-zero type encoding, if
|
/* Return a selector with name 'name' and a non-zero type encoding, if
|
||||||
any such selector is registered with the runtime. If there is no
|
there is a single selector with a type, and with that name,
|
||||||
such selector, NULL is returned. Return NULL if 'name' is NULL.
|
registered with the runtime. If there is no such selector, or if
|
||||||
|
there are multiple selectors with the same name but conflicting
|
||||||
|
types, NULL is returned. Return NULL if 'name' is NULL.
|
||||||
|
|
||||||
This is useful if you have the name of the selector, and would
|
This is useful if you have the name of the selector, and would
|
||||||
really like to get a selector for it that includes the type
|
really like to get a selector for it that includes the type
|
||||||
encoding. Unfortunately, if the program contains multiple selector
|
encoding. Unfortunately, if the program contains multiple selector
|
||||||
with the same name but different types, sel_getTypedSelector
|
with the same name but different types, sel_getTypedSelector can
|
||||||
returns a random one of them, which may not be the right one.
|
not possibly know which one you need, and so will return NULL.
|
||||||
|
|
||||||
Compatibility Note: the Apple/NeXT runtime has untyped selectors,
|
Compatibility Note: the Apple/NeXT runtime has untyped selectors,
|
||||||
so it does not have this function, which is specific to the GNU
|
so it does not have this function, which is specific to the GNU
|
||||||
|
|
|
@ -369,6 +369,7 @@ sel_getTypedSelector (const char *name)
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
struct objc_list *l;
|
struct objc_list *l;
|
||||||
|
SEL returnValue = NULL;
|
||||||
|
|
||||||
for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
|
for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
|
||||||
l; l = l->tail)
|
l; l = l->tail)
|
||||||
|
@ -376,9 +377,39 @@ sel_getTypedSelector (const char *name)
|
||||||
SEL s = (SEL) l->head;
|
SEL s = (SEL) l->head;
|
||||||
if (s->sel_types)
|
if (s->sel_types)
|
||||||
{
|
{
|
||||||
objc_mutex_unlock (__objc_runtime_mutex);
|
if (returnValue == NULL)
|
||||||
return s;
|
{
|
||||||
|
/* First typed selector that we find. Keep it in
|
||||||
|
returnValue, but keep checking as we want to
|
||||||
|
detect conflicts. */
|
||||||
|
returnValue = s;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We had already found a typed selectors, so we
|
||||||
|
have multiple ones. Double-check that they have
|
||||||
|
different types, just in case for some reason we
|
||||||
|
got duplicates with the same types. If so, it's
|
||||||
|
OK, we'll ignore the duplicate. */
|
||||||
|
if (returnValue->sel_types == s->sel_types)
|
||||||
|
continue;
|
||||||
|
else if (sel_types_match (returnValue->sel_types, s->sel_types))
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The types of the two selectors are different;
|
||||||
|
it's a conflict. Too bad. Return NULL. */
|
||||||
|
objc_mutex_unlock (__objc_runtime_mutex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue != NULL)
|
||||||
|
{
|
||||||
|
objc_mutex_unlock (__objc_runtime_mutex);
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue