* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Don't
[official-gcc.git] / gcc / testsuite / objc.dg / special / load-category-3.m
blobb89d8f15286034f06fb35c38c1139ca04dcf1bef
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* This test is identical to load-category-2, but the classes and
6    categories are created in inverted order in the modules, to test
7    that you can load classes first, or categories first, and it all
8    still works in both cases.  */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <objc/objc.h>
14 #include "load-category-3.h"
16 @implementation TestClass2 (Category)
17 + load
19   printf ("[TestClass2(Category) +load]\n");
21   /* Check that the corresponding class's +load was done.  */
22   check_that_load_step_was_completed (1);
24   complete_load_step (4);
26 @end
28 @implementation TestClass3 (Category)
29 + load
31   printf ("[TestClass3(Category) +load]\n");
33   /* Check that the corresponding class's +load was done.  */
34   check_that_load_step_was_completed (2);
36   complete_load_step (5);
38 @end
40 @implementation TestClass1 (Category)
41 + load
43   printf ("[TestClass1(Category) +load]\n");
45   /* Check that the corresponding class's +load was done.  */
46   check_that_load_step_was_completed (0);
48   complete_load_step (3);
50 @end
52 static BOOL load_step_completed[6] = { NO, NO, NO, NO, NO, NO };
54 void complete_load_step (int load_step)
56   load_step_completed[load_step] = YES;
59 void check_that_load_step_was_completed (int load_step)
61   if (load_step_completed[load_step] == NO)
62     {
63       printf ("Load step %d was not completed but should have been\n", load_step);
64       abort ();
65     }
68 void check_that_load_step_was_not_completed (int load_step)
70   if (load_step_completed[load_step] == YES)
71     {
72       printf ("Load step %d was completed but shouldn't have been\n", load_step);
73       abort ();
74     }
77 int main (void)
79   check_that_load_step_was_completed (0);
80   check_that_load_step_was_completed (1);
81   check_that_load_step_was_completed (2);
82   check_that_load_step_was_completed (3);
83   check_that_load_step_was_completed (4);
84   check_that_load_step_was_completed (5);
86   return 0;