| 1 |
/* Test if the Objective-C @encode machinery distinguishes between |
| 2 |
'BOOL *' (which should be encoded as a pointer to BOOL) and 'char *' (which |
| 3 |
should be encoded as '*'). This is somewhat tricky wrt the NeXT runtime, |
| 4 |
where we have 'typedef char BOOL'. */ |
| 5 |
/* Contributed by Ziemowit Laski <[email protected]>. */ |
| 6 |
/* { dg-do run } */ |
| 7 |
#include <string.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include <objc/objc.h> |
| 10 |
|
| 11 |
int main(void) { |
| 12 |
const char *BOOL_ptr = @encode(BOOL *); |
| 13 |
const char *BOOL_ = @encode(BOOL); |
| 14 |
const char *char_ptr = @encode(char *); |
| 15 |
|
| 16 |
if(*BOOL_ptr != '^' || strcmp(BOOL_ptr + 1, BOOL_)) |
| 17 |
abort(); |
| 18 |
|
| 19 |
if(strcmp(char_ptr, "*")) |
| 20 |
abort(); |
| 21 |
|
| 22 |
return 0; |
| 23 |
} |