mirror of
https://github.com/darlinghq/darling-libobjc2.git
synced 2024-11-23 12:19:44 +00:00
Merge pull request #4 from ngrewe/nil_exception
Fix throwing nil exceptions.
This commit is contained in:
commit
27933a9be7
@ -26,6 +26,7 @@ set(TESTS
|
||||
WeakReferences_arc.m
|
||||
objc_msgSend.m
|
||||
msgInterpose.m
|
||||
NilException.m
|
||||
MethodArguments.m
|
||||
)
|
||||
|
||||
|
49
Test/NilException.m
Normal file
49
Test/NilException.m
Normal file
@ -0,0 +1,49 @@
|
||||
#include "Test.h"
|
||||
|
||||
|
||||
#ifdef __has_attribute
|
||||
#if __has_attribute(objc_root_class)
|
||||
__attribute__((objc_root_class))
|
||||
#endif
|
||||
#endif
|
||||
@interface NSObject
|
||||
{
|
||||
Class isa;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSObject
|
||||
+ (id)new
|
||||
{
|
||||
return class_createInstance(self, 0);
|
||||
}
|
||||
@end
|
||||
int main(void)
|
||||
{
|
||||
BOOL caught_exception = NO;
|
||||
@try
|
||||
{
|
||||
@throw(nil);
|
||||
}
|
||||
@catch (NSObject* o)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
@catch (id x)
|
||||
{
|
||||
assert(nil == x);
|
||||
caught_exception = YES;
|
||||
}
|
||||
assert(caught_exception == YES);
|
||||
caught_exception = NO;
|
||||
@try
|
||||
{
|
||||
@throw(nil);
|
||||
}
|
||||
@catch (...)
|
||||
{
|
||||
caught_exception = YES;
|
||||
}
|
||||
assert(caught_exception == YES);
|
||||
return 0;
|
||||
}
|
@ -358,7 +358,10 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version,
|
||||
else if (!foreignException)
|
||||
{
|
||||
ex = objc_exception_from_header(exceptionObject);
|
||||
thrown_class = classForObject(ex->object);
|
||||
if (ex->object != nil)
|
||||
{
|
||||
thrown_class = classForObject(ex->object);
|
||||
}
|
||||
}
|
||||
else if (_objc_class_for_boxing_foreign_exception)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user