xref: /php-src/ext/ffi/tests/bug78270_2.phpt (revision 93455824)
1--TEST--
2FR #78270 (Usage of __vectorcall convention with FFI)
3--EXTENSIONS--
4ffi
5zend_test
6--SKIPIF--
7<?php
8if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
9if (PHP_DEBUG || getenv('SKIP_ASAN')) die("xfail: FFI cleanup after parser error is not implemented");
10
11require_once('utils.inc');
12try {
13    FFI::cdef(<<<EOC
14        __vectorcall int bug78270(const char *str, size_t str_len);
15        EOC, "php_zend_test.dll");
16} catch (FFI\ParserException $ex) {
17    die('skip __vectorcall not supported');
18}
19?>
20--FILE--
21<?php
22$x86 = (PHP_INT_SIZE === 4);
23$arglists = array(
24    'int, int, int, int, int, int, int' => true,
25    'double, int, int, int, int, int, int' => !$x86,
26    'int, double, int, int, int, int, int' => !$x86,
27    'int, int, double, int, int, int, int' => !$x86,
28    'int, int, int, double, int, int, int' => !$x86,
29    'int, int, int, int, double, int, int' => false,
30    'int, int, int, int, int, double, int' => false,
31    'int, int, int, int, int, int, double' => true,
32);
33foreach ($arglists as $arglist => $allowed) {
34    $signature = "__vectorcall void foobar($arglist);";
35    try {
36        $ffi = FFI::cdef($signature);
37    } catch (FFI\ParserException $ex) {
38        if ($allowed) {
39            echo "($arglist): unexpected ParserException\n";
40        }
41    } catch (FFI\Exception $ex) {
42        if (!$allowed) {
43            echo "($arglist): unexpected Exception\n";
44        }
45    }
46}
47?>
48--EXPECT--
49