Skip to content

Commit

Permalink
Fixed incorrect error message
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Mar 19, 2019
1 parent 14359eb commit 2ccc27b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/ffi/ffi.g
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down
2 changes: 1 addition & 1 deletion ext/ffi/ffi_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 19 additions & 0 deletions ext/ffi/tests/043.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
FFI 043: Type redeclaration
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
FFI::cdef("
typedef int a;
typedef unsigned int a;
");
?>
--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

0 comments on commit 2ccc27b

Please sign in to comment.