summaryrefslogtreecommitdiff
path: root/ext/ffi/tests/002.phpt
blob: 353f36139c121a81c8bb1a40f55e09e7f8fc2f69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
--TEST--
FFI 002: Check C declaration parser
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
echo "Empty declaration\n";
$ffi = FFI::cdef(<<<EOF
EOF
);
echo "  ok\n";

echo "Various declarations\n";
$ffi = FFI::cdef(<<<EOF
    /* allowed storage classes */
    typedef  int type1;
//	extern   int var2;
    static   int var3;
    auto     int var4;
    register int var5;

    /* allowed types */
    typedef void type6;
    typedef char type7;                     /* sint8_t or uint8_t */
    typedef signed char type8;              /* sint8_t  */
    typedef unsigned char type9;            /* uint8_t  */
    typedef short type10;                   /* sint16_t */
    typedef signed short type11;            /* sint16_t */
    typedef short int type12;               /* sint16_t */
    typedef signed short int type13;        /* sint16_t */
    typedef unsigned short type14;          /* uint16_t */
    typedef unsigned short int type15;      /* uint16_t */
    typedef int type16;                     /* sint32_t */
    typedef signed type17;                  /* sint32_t */
    typedef signed int type18;              /* sint32_t */
    typedef unsigned type19;                /* uint32_t */
    typedef unsigned int type20;            /* uint32_t */
    typedef long type21;                    /* sint32_t or sint64_t */
    typedef signed long type22;             /* sint32_t or sint64_t */
    typedef long int type23;                /* sint32_t or sint64_t */
    typedef signed long int type24;         /* sint32_t or sint64_t */
    typedef unsigned long type25;           /* uint32_t or uint64_t */
    typedef unsigned long int type25_2;     /* uint32_t or uint64_t */
    typedef long long type26;               /* sint64_t */
    typedef signed long long type27;        /* sint64_t */
    typedef long long int type28;           /* sint64_t */
    typedef signed long long int type29;    /* sint64_t */
    typedef unsigned long long type30;      /* uint64_t */
    typedef unsigned long long int type31;  /* uint64_t */
    typedef float type32;
    typedef double type33;
    typedef long double type34;
    typedef _Bool type35;
//	typedef float _Complex type36;
//	typedef double _Complex type36_2;
//	typedef long double _Complex type36_3;

    /* struct and union */
    struct tag1;
    union tag2;
    typedef struct tag1 {int x; int y;} type37;
    typedef union tag2 {int x; int y;} type38;
    typedef struct {int x, y; int z;} type39;
    typedef struct {unsigned int x:8, y:8;} type40;
    typedef struct {unsigned int x:8, :8, y:8;} type41;

    /* enum */
    enum tag3;
    typedef enum tag3 {A,B,C} type42;
    typedef enum {D,E=10,F,} type43;

    /* type qualifiers */
    typedef void* type46;
    typedef const void* type47;
    typedef restrict void* type48;
    typedef volatile void* type49;
    typedef _Atomic void* type50;
    typedef const volatile void* type51;

    /* function specifiers */
    static void f1();
    static inline void f2();
    static _Noreturn void f3();

    /* align specifier */
    typedef double _Alignas(char) type52;
    typedef double _Alignas(1) type53;

    /* pointers */
    typedef void * type54;
    typedef void ** type55;
    typedef const void * const volatile * const type56;

    /* arrays */
    typedef char type57[];
    typedef char type58[const];
    typedef char type59[const volatile];
    typedef char type60[10];
    typedef char type61[const 10];
    typedef char type62[static 10];
    typedef char type63[static const volatile 10];
    typedef char type64[const volatile static 10];
    typedef char type65[];
    typedef char type66[const volatile];
    typedef char type67[10][10];

    /* functions */
    static void f4();
    static void f5(void);
    static void f6(int x);
    static void f7(int x, int y);
    static void f8(int x, int y, ...);
    static void f9(int, int);
    static void f9(int, int, ...);
    static void f10(...);
    static void f11(const char *name);
    static void f12(const char *);
    static void f13(const int a[5]);
    static void f14(const int[5]);

    /* nested */
    typedef int *type69[4];
    typedef int (*type70)[4];
    typedef int (*type71[3])(int *x, int *y);
    typedef int (*type72(int (*)(long), int))(int, ...);
EOF
);
echo "  ok\n";
?>
--EXPECT--
Empty declaration
  ok
Various declarations
  ok