Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fixed bug #79576 ("TYPE *" shows unhelpful message when type is not defined)
This commit is contained in:
Dmitry Stogov 2021-09-15 14:53:00 +03:00
commit 46c09a34d5
4 changed files with 42 additions and 2 deletions

4
NEWS
View file

@ -9,6 +9,10 @@ PHP NEWS
. Fixed bug #81433 (DOMElement::setIdAttribute() called twice may remove ID).
(Viktor Volkov)
- FFI:
. Fixed bug #79576 ("TYPE *" shows unhelpful message when type is not
defined). (Dmitry)
- Shmop:
. Fixed bug #81407 (shmop_open won't attach and causes php to crash). (cmb)

View file

@ -143,7 +143,7 @@ declaration_specifiers(zend_ffi_dcl *dcl):
specifier_qualifier_list(zend_ffi_dcl *dcl):
"__extension__"?
( ?{sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text)}
( ?{sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text) || (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) == 0}
( type_specifier(dcl)
| type_qualifier(dcl)
| attributes(dcl)

View file

@ -2188,7 +2188,7 @@ static int parse_specifier_qualifier_list(int sym, zend_ffi_dcl *dcl) {
} else {
yy_error_sym("unexpected", sym);
}
} while ((YY_IN_SET(sym, (YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\377\377\107\360\017\000\000\000\002\000")) && (sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text)));
} while ((YY_IN_SET(sym, (YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\377\377\107\360\017\000\000\000\002\000")) && (sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text) || (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) == 0));
return sym;
}

View file

@ -0,0 +1,36 @@
--TEST--
Bug #79576 ("TYPE *" shows unhelpful message when type is not defined)
--EXTENSIONS--
ffi
--SKIPIF--
<?php
if (PHP_DEBUG || getenv('SKIP_ASAN')) echo "xfail: FFI cleanup after parser error is nor implemented";
?>
--FILE--
<?php
try {
FFI::cdef('struct tree *get_tree(const oid *, size_t, struct tree *);');
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef('struct tree *get_tree(oid, size_t, struct tree *);');
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef('
typedef struct _simple_struct {
const some_not_declared_type **property;
} simple_struct;
');
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
DONE
--EXPECT--
FFI\ParserException: undefined C type 'oid' at line 1
FFI\ParserException: undefined C type 'oid' at line 1
FFI\ParserException: undefined C type 'some_not_declared_type' at line 3
DONE