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