PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / objc.dg / demangle-1.m
blob42b79a9eb0a48b83cd36fcad4f0d6e7c1bd8fa20
1 /* Test demangling an Objective-C method.  */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stdio.h>
9 #include <objc/objc.h>
11 @interface DemangleTest
13   Class isa;
15 + (id) initialize;
16 + (int) testFunction1;
17 + (int) test_function2;
18 + (int) __testFunction3: (int)unused  andArgument: (char)unused2;
19 @end
21 @implementation DemangleTest
22 + (id) initialize { return self; }
23 + (int) testFunction1
25   printf ("%s\n", __PRETTY_FUNCTION__);
26   return strcmp (__PRETTY_FUNCTION__, "+[DemangleTest testFunction1]");
28 /* Note that in general, due to how mangling is done, it's impossible
29    to get the demangling right for all functions containing '_' in the
30    name.  But at least we should be able to get that right for single
31    argument ones that don't end with '_', such as the following
32    one.  */
33 + (int) test_function2
35   printf ("%s\n", __PRETTY_FUNCTION__);
36   return strcmp (__PRETTY_FUNCTION__, "+[DemangleTest test_function2]");
38 + (int) __testFunction3: (int)unused   andArgument: (char)unused2
40   printf ("%s\n", __PRETTY_FUNCTION__);
41   return strcmp (__PRETTY_FUNCTION__, "+[DemangleTest __testFunction3:andArgument:]");
43 @end
45 int main ()
47   if ([DemangleTest testFunction1] != 0)
48       abort ();
50   if ([DemangleTest test_function2] != 0)
51     abort ();
53   if ([DemangleTest __testFunction3:0 andArgument: 'c'] != 0)
54       abort ();
56   return 0;