mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
bd9f4fa676
For rationale, see https://github.com/php/php-src/pull/6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
92 lines
2.3 KiB
PHP
92 lines
2.3 KiB
PHP
--TEST--
|
|
FFI 027: Incomplete and variable length arrays
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
try {
|
|
$p = FFI::new("int[*]");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
FFI::cdef("static int (*foo)[*];");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
FFI::cdef("typedef int foo[*];");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
FFI::cdef("static void foo(int[*][*]);");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
var_dump(FFI::sizeof(FFI::new("int[0]")));
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
var_dump(FFI::sizeof(FFI::new("int[]")));
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]"))));
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
FFI::cdef("struct _x {int a; int b[];};");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$f = FFI::cdef("typedef int(*foo)[];");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$f = FFI::cdef("typedef int foo[][2];");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$f = FFI::cdef("typedef int foo[];");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
try {
|
|
$f = FFI::cdef("static int foo(int[]);");
|
|
echo "ok\n";
|
|
} catch (Throwable $e) {
|
|
echo get_class($e) . ": " . $e->getMessage()."\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
|
|
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
|
|
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
|
|
ok
|
|
FFI\Exception: Cannot instantiate FFI\CData of zero size
|
|
FFI\ParserException: "[]" is not allowed at line 1
|
|
FFI\ParserException: "[]" is not allowed at line 1
|
|
ok
|
|
ok
|
|
ok
|
|
ok
|
|
ok
|