OSDN Git Service

2010-03-25 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / encode-1.m
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 <zlaski@apple.com>.  */
6 /* { dg-do run } */
7 /* { dg-options "-fnext-runtime" } */
8 #include <string.h>           
9 #include <stdlib.h>
10 #include <objc/objc.h>
11
12 int main(void) {
13   const char *BOOL_ptr = @encode(BOOL *);
14   const char *BOOL_ = @encode(BOOL);
15   const char *char_ptr = @encode(char *);
16
17   if(*BOOL_ptr != '^' || strcmp(BOOL_ptr + 1, BOOL_))
18     abort();
19
20   if(strcmp(char_ptr, "*"))
21     abort();
22
23   return 0;
24 }