xref: /PHP-7.4/ext/ffi/tests/028.phpt (revision e089d506)
1--TEST--
2FFI 028: Incomplete arrays inside structure
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9try {
10	FFI::cdef("struct _x {int a; int b[0];};");
11	echo "ok\n";
12} catch (Throwable $e) {
13	echo get_class($e) . ": " . $e->getMessage()."\n";
14}
15try {
16	FFI::cdef("struct _x {int a; int b[];};");
17	echo "ok\n";
18} catch (Throwable $e) {
19	echo get_class($e) . ": " . $e->getMessage()."\n";
20}
21try {
22	FFI::cdef("struct _x {int a[0]; int b;};");
23	echo "ok\n";
24} catch (Throwable $e) {
25	echo get_class($e) . ": " . $e->getMessage()."\n";
26}
27try {
28	FFI::cdef("struct _x {int a[]; int b;};");
29	echo "ok\n";
30} catch (Throwable $e) {
31	echo get_class($e) . ": " . $e->getMessage()."\n";
32}
33try {
34	FFI::cdef("struct _x { struct {int a; int b[];}; int c;};");
35	echo "ok\n";
36} catch (Throwable $e) {
37	echo get_class($e) . ": " . $e->getMessage()."\n";
38}
39try {
40	FFI::cdef("union _x {int a; int b[];};");
41	echo "ok\n";
42} catch (Throwable $e) {
43	echo get_class($e) . ": " . $e->getMessage()."\n";
44}
45?>
46--EXPECT--
47ok
48ok
49ok
50FFI\ParserException: flexible array member not at end of struct at line 1
51FFI\ParserException: flexible array member not at end of struct at line 1
52FFI\ParserException: flexible array member in union at line 1
53