diff --git a/ext/ffi/ffi.g b/ext/ffi/ffi.g index 80b41fddc3c..9ffe3c5fa64 100644 --- a/ext/ffi/ffi.g +++ b/ext/ffi/ffi.g @@ -92,7 +92,7 @@ declarations: ; declaration_specifiers(zend_ffi_dcl *dcl): - ( ?{sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text)} + ( ?{sym != YY_ID || !(dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS)} ( {if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);} "typedef" {dcl->flags |= ZEND_FFI_DCL_TYPEDEF;} diff --git a/ext/ffi/ffi_parser.c b/ext/ffi/ffi_parser.c index 1606bef16f0..31caef6bf56 100644 --- a/ext/ffi/ffi_parser.c +++ b/ext/ffi/ffi_parser.c @@ -3588,7 +3588,7 @@ static int parse_declaration_specifiers(int sym, zend_ffi_dcl *dcl) { default: yy_error_sym("unexpected", sym); } - } while ((YY_IN_SET(sym, (YY_TYPEDEF,YY_EXTERN,YY_STATIC,YY_AUTO,YY_REGISTER,YY_INLINE,YY___INLINE,YY___INLINE__,YY__NORETURN,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY__ALIGNAS,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,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), "\370\377\371\377\377\037\301\001\000\000\040\000")) && (sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text))); + } while ((YY_IN_SET(sym, (YY_TYPEDEF,YY_EXTERN,YY_STATIC,YY_AUTO,YY_REGISTER,YY_INLINE,YY___INLINE,YY___INLINE__,YY__NORETURN,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY__ALIGNAS,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,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), "\370\377\371\377\377\037\301\001\000\000\040\000")) && (sym != YY_ID || !(dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS))); return sym; } diff --git a/ext/ffi/tests/043.phpt b/ext/ffi/tests/043.phpt new file mode 100644 index 00000000000..f4400a9adc9 --- /dev/null +++ b/ext/ffi/tests/043.phpt @@ -0,0 +1,19 @@ +--TEST-- +FFI 043: Type redeclaration +--SKIPIF-- + +--INI-- +ffi.enable=1 +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught FFI\ParserException: redeclaration of 'a' at line 3 in %s043.php:2 +Stack trace: +#0 %s043.php(2): FFI::cdef('%s') +#1 {main} + thrown in %s043.php on line 2