-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ngrewe/nil_exception
Fix throwing nil exceptions.
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ set(TESTS | |
WeakReferences_arc.m | ||
objc_msgSend.m | ||
msgInterpose.m | ||
NilException.m | ||
MethodArguments.m | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters