Skip to content

Commit 841b18a

Browse files
committed
A few FFI related fixes
1 parent 263a4a6 commit 841b18a

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

Zend/tests/attributes/013_class_scope.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait T1
3434
class C2
3535
{
3636
use T1;
37-
37+
3838
private const FOO = 'bar';
3939
}
4040

@@ -109,7 +109,7 @@ Array
109109
[1] => bar
110110
)
111111
string(7) "ERROR 1"
112-
string(36) "Undefined class constant 'self::FOO'"
112+
string(34) "Undefined class constant self::FOO"
113113

114114
bool(true)
115115
string(3) "bar"

ext/ffi/ffi.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -3445,7 +3445,7 @@ static void zend_ffi_throw_parser_error(const char *format, ...) /* {{{ */
34453445
static int zend_ffi_validate_vla(zend_ffi_type *type) /* {{{ */
34463446
{
34473447
if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) {
3448-
zend_ffi_throw_parser_error("'[*]' not allowed in other than function prototype scope at line %d", FFI_G(line));
3448+
zend_ffi_throw_parser_error("\"[*]\" is not allowed in other than function prototype scope at line %d", FFI_G(line));
34493449
return FAILURE;
34503450
}
34513451
return SUCCESS;
@@ -3462,11 +3462,11 @@ static int zend_ffi_validate_incomplete_type(zend_ffi_type *type, zend_bool allo
34623462
ZEND_HASH_FOREACH_STR_KEY_PTR(FFI_G(tags), key, tag) {
34633463
if (ZEND_FFI_TYPE(tag->type) == type) {
34643464
if (type->kind == ZEND_FFI_TYPE_ENUM) {
3465-
zend_ffi_throw_parser_error("Incomplete \"enum %s\" at line %d", ZSTR_VAL(key), FFI_G(line));
3465+
zend_ffi_throw_parser_error("Incomplete enum %s at line %d", ZSTR_VAL(key), FFI_G(line));
34663466
} else if (type->attr & ZEND_FFI_ATTR_UNION) {
3467-
zend_ffi_throw_parser_error("Incomplete \"union %s\" at line %d", ZSTR_VAL(key), FFI_G(line));
3467+
zend_ffi_throw_parser_error("Incomplete union %s at line %d", ZSTR_VAL(key), FFI_G(line));
34683468
} else {
3469-
zend_ffi_throw_parser_error("Incomplete \"struct %s\" at line %d", ZSTR_VAL(key), FFI_G(line));
3469+
zend_ffi_throw_parser_error("Incomplete struct %s at line %d", ZSTR_VAL(key), FFI_G(line));
34703470
}
34713471
return FAILURE;
34723472
}
@@ -3486,10 +3486,10 @@ static int zend_ffi_validate_incomplete_type(zend_ffi_type *type, zend_bool allo
34863486
zend_ffi_throw_parser_error("Incomplete type at line %d", FFI_G(line));
34873487
return FAILURE;
34883488
} else if (!allow_incomplete_array && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) {
3489-
zend_ffi_throw_parser_error("\"[]\" not allowed at line %d", FFI_G(line));
3489+
zend_ffi_throw_parser_error("\"[]\" is not allowed at line %d", FFI_G(line));
34903490
return FAILURE;
34913491
} else if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) {
3492-
zend_ffi_throw_parser_error("\"[*]\" not allowed in other than function prototype scope at line %d", FFI_G(line));
3492+
zend_ffi_throw_parser_error("\"[*]\" is not allowed in other than function prototype scope at line %d", FFI_G(line));
34933493
return FAILURE;
34943494
}
34953495
return SUCCESS;
@@ -3499,7 +3499,7 @@ static int zend_ffi_validate_incomplete_type(zend_ffi_type *type, zend_bool allo
34993499
static int zend_ffi_validate_type(zend_ffi_type *type, zend_bool allow_incomplete_tag, zend_bool allow_incomplete_array) /* {{{ */
35003500
{
35013501
if (type->kind == ZEND_FFI_TYPE_VOID) {
3502-
zend_ffi_throw_parser_error("void type is not allowed at line %d", FFI_G(line));
3502+
zend_ffi_throw_parser_error("Type void is not allowed at line %d", FFI_G(line));
35033503
return FAILURE;
35043504
}
35053505
return zend_ffi_validate_incomplete_type(type, allow_incomplete_tag, allow_incomplete_array);
@@ -3509,7 +3509,7 @@ static int zend_ffi_validate_type(zend_ffi_type *type, zend_bool allow_incomplet
35093509
static int zend_ffi_validate_var_type(zend_ffi_type *type, zend_bool allow_incomplete_array) /* {{{ */
35103510
{
35113511
if (type->kind == ZEND_FFI_TYPE_FUNC) {
3512-
zend_ffi_throw_parser_error("function type is not allowed at line %d", FFI_G(line));
3512+
zend_ffi_throw_parser_error("Type function is not allowed at line %d", FFI_G(line));
35133513
return FAILURE;
35143514
}
35153515
return zend_ffi_validate_type(type, 0, allow_incomplete_array);
@@ -4040,7 +4040,7 @@ ZEND_METHOD(FFI, arrayType) /* {{{ */
40404040
zend_throw_error(zend_ffi_exception_ce, "Only the leftmost array can be undimensioned");
40414041
RETURN_THROWS();
40424042
} else if (type->kind == ZEND_FFI_TYPE_VOID) {
4043-
zend_throw_error(zend_ffi_exception_ce, "Array of 'void' is not allowed");
4043+
zend_throw_error(zend_ffi_exception_ce, "Array of void type is not allowed");
40444044
RETURN_THROWS();
40454045
} else if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG) {
40464046
zend_throw_error(zend_ffi_exception_ce, "Array of incomplete type is not allowed");
@@ -5897,7 +5897,7 @@ void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args, zend_ffi_dcl *n
58975897
zend_ffi_cleanup_dcl(dcl);
58985898
zend_hash_destroy(args);
58995899
pefree(args, FFI_G(persistent));
5900-
zend_ffi_parser_error("void type is not allowed at line %d", FFI_G(line));
5900+
zend_ffi_parser_error("Type void is not allowed at line %d", FFI_G(line));
59015901
return;
59025902
} else {
59035903
no_args = 1;
@@ -5927,7 +5927,7 @@ void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args, zend_ffi_dcl *n
59275927
zend_ffi_cleanup_dcl(dcl);
59285928
zend_hash_destroy(args);
59295929
pefree(args, FFI_G(persistent));
5930-
zend_ffi_parser_error("float/double type is not allowed at position " ZEND_ULONG_FMT " with __vectorcall at line %d", i+1, FFI_G(line));
5930+
zend_ffi_parser_error("Type float/double is not allowed at position " ZEND_ULONG_FMT " with __vectorcall at line %d", i+1, FFI_G(line));
59315931
return;
59325932
}
59335933
} ZEND_HASH_FOREACH_END();

ext/ffi/tests/003.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ object(FFI\CData:struct _d)#%d (1) {
5858
["x"]=>
5959
int(0)
6060
}
61-
FFI\ParserException: Incomplete 'struct _e' at line 1
62-
FFI\ParserException: Incomplete 'struct _f' at line 1
61+
FFI\ParserException: Incomplete struct _e at line 1
62+
FFI\ParserException: Incomplete struct _f at line 1
6363
ok

ext/ffi/tests/004.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ object(FFI\CData:int32_t[2])#%d (2) {
8282
[1]=>
8383
int(0)
8484
}
85-
FFI\ParserException: Incomplete 'enum _e' at line 1
86-
FFI\ParserException: Incomplete 'enum _f' at line 1
85+
FFI\ParserException: Incomplete enum _e at line 1
86+
FFI\ParserException: Incomplete enum _f at line 1
8787
ok

ext/ffi/tests/013.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ try {
5757
int(1)
5858
int(2)
5959
int(3)
60-
FFI\ParserException: 'void' type is not allowed at line 1
61-
FFI\ParserException: 'void' type is not allowed at line 1
60+
FFI\ParserException: Type void is not allowed at line 1
61+
FFI\ParserException: Type void is not allowed at line 1
6262
FFI\ParserException: Function returning array is not allowed at line 1
6363
FFI\ParserException: Array of functions is not allowed at line 1
6464
FFI\ParserException: Function returning function is not allowed at line 1

ext/ffi/tests/015.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ try {
5757
?>
5858
ok
5959
--EXPECT--
60-
FFI\ParserException: Incomplete 'struct DIR' at line 1
60+
FFI\ParserException: Incomplete struct DIR at line 1
6161
ok
62-
FFI\ParserException: Incomplete 'struct DIR' at line 1
62+
FFI\ParserException: Incomplete struct DIR at line 1
6363
ok
6464
ok
6565
ok

ext/ffi/tests/016.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try {
2727
?>
2828
ok
2929
--EXPECT--
30-
FFI\ParserException: 'function' type is not allowed at line 1
30+
FFI\ParserException: Type function is not allowed at line 1
3131
FFI\ParserException: Struct/union can't contain an instance of itself at line 1
3232
ok
3333
ok

ext/ffi/tests/017.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ try {
2424
?>
2525
ok
2626
--EXPECTF--
27-
FFI\ParserException: 'function' type is not allowed at line 1
27+
FFI\ParserException: Type function is not allowed at line 1
2828
FFI\ParserException: Struct/union can't contain an instance of itself at line 1
2929
object(FFI\CData:struct X)#%d (1) {
3030
["ptr"]=>

ext/ffi/tests/018.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ try {
2121
?>
2222
ok
2323
--EXPECT--
24-
FFI\ParserException: Incomplete 'struct X' at line 1
24+
FFI\ParserException: Incomplete struct X at line 1
2525
ok
2626
ok

ext/ffi/tests/027.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ try {
7777
}
7878
?>
7979
--EXPECT--
80-
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
81-
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
82-
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
80+
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
81+
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
82+
FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
8383
ok
8484
FFI\Exception: Cannot instantiate FFI\CData of zero size
85-
FFI\ParserException: '[]' not allowed at line 1
86-
FFI\ParserException: '[]' not allowed at line 1
85+
FFI\ParserException: "[]" is not allowed at line 1
86+
FFI\ParserException: "[]" is not allowed at line 1
8787
ok
8888
ok
8989
ok

ext/ffi/tests/043.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef unsigned int a;
1212
");
1313
?>
1414
--EXPECTF--
15-
Fatal error: Uncaught FFI\ParserException: redeclaration of 'a' at line 3 in %s043.php:2
15+
Fatal error: Uncaught FFI\ParserException: Redeclaration of "a" at line 3 in %s043.php:2
1616
Stack trace:
1717
#0 %s043.php(2): FFI::cdef('%s')
1818
#1 {main}

0 commit comments

Comments
 (0)