gcc/testsuite/objc/execute/load.m
raw| 1 | /* Contributed by Nicola Pero - Wed Mar 7 17:55:04 CET 2001 */ |
| 2 | #include <objc/objc.h> |
| 3 | |
| 4 | /* Test that +load is automatically called before main is run */ |
| 5 | |
| 6 | static int static_variable = 0; |
| 7 | |
| 8 | @interface TestClass |
| 9 | { |
| 10 | Class isa; |
| 11 | } |
| 12 | + (void) load; |
| 13 | @end |
| 14 | |
| 15 | @implementation TestClass |
| 16 | + (void) load |
| 17 | { |
| 18 | static_variable = 1; |
| 19 | } |
| 20 | @end |
| 21 | |
| 22 | int main (void) |
| 23 | { |
| 24 | if (static_variable != 1) |
| 25 | { |
| 26 | abort (); |
| 27 | } |
| 28 | |
| 29 | return 0; |
| 30 | } |