xref: /PHP-8.2/ext/ffi/tests/015.phpt (revision bd9f4fa6)
1--TEST--
2FFI 015: Incomplete type usage
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9try {
10    FFI::cdef("struct DIR; static struct DIR dir;");
11    echo "ok\n";
12} catch (Throwable $e) {
13    echo get_class($e) . ": " . $e->getMessage()."\n";
14}
15try {
16    FFI::cdef("struct DIR; static struct DIR *ptr;");
17    echo "ok\n";
18} catch (Throwable $e) {
19    echo get_class($e) . ": " . $e->getMessage()."\n";
20}
21try {
22    FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;");
23    echo "ok\n";
24} catch (Throwable $e) {
25    echo get_class($e) . ": " . $e->getMessage()."\n";
26}
27try {
28    FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;");
29    echo "ok\n";
30} catch (Throwable $e) {
31    echo get_class($e) . ": " . $e->getMessage()."\n";
32}
33try {
34    FFI::cdef("struct DIR; static struct DIR foo();");
35    echo "ok\n";
36} catch (Throwable $e) {
37    echo get_class($e) . ": " . $e->getMessage()."\n";
38}
39try {
40    FFI::cdef("struct DIR; static struct DIR* foo();");
41    echo "ok\n";
42} catch (Throwable $e) {
43    echo get_class($e) . ": " . $e->getMessage()."\n";
44}
45try {
46    FFI::cdef("struct DIR; static void foo(struct DIR);");
47    echo "ok\n";
48} catch (Throwable $e) {
49    echo get_class($e) . ": " . $e->getMessage()."\n";
50}
51try {
52    FFI::cdef("struct DIR; static void foo(struct DIR*);");
53    echo "ok\n";
54} catch (Throwable $e) {
55    echo get_class($e) . ": " . $e->getMessage()."\n";
56}
57?>
58ok
59--EXPECT--
60FFI\ParserException: Incomplete struct "DIR" at line 1
61ok
62FFI\ParserException: Incomplete struct "DIR" at line 1
63ok
64ok
65ok
66ok
67ok
68ok
69