diff options
| author | Dmitry Stogov <dmitry@php.net> | 2007-09-05 07:24:52 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2007-09-05 07:24:52 +0000 |
| commit | 45c6b4db99e82f218a5a91b4d94c6e29fccec5dc (patch) | |
| tree | bcd7bdad709fe2758338c651af526d3ceffc9304 | |
| parent | 210bcfd89b2e077ec7776c93567ee2b5eff4dad8 (diff) | |
| download | php-git-45c6b4db99e82f218a5a91b4d94c6e29fccec5dc.tar.gz | |
Bug #42541 (Check for namespace decl. on first line doesn't work when extended info is on)
| -rw-r--r-- | Zend/zend_compile.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a017c71084..dc7b2c7f1a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4478,7 +4478,15 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC) /* {{{ */ * want to tell them to put declare() at the top. */ if (CG(active_op_array)->last > 0) { - zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first statement in the script"); + /* ignore ZEND_EXT_STMT */ + int num = CG(active_op_array)->last; + while (num > 0 && + CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT) { + --num; + } + if (num > 0) { + zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first statement in the script"); + } } convert_to_string(&val->u.constant); if (zend_prepare_scanner_converters(Z_STRVAL(val->u.constant), 1 TSRMLS_CC) == FAILURE) { @@ -5046,7 +5054,15 @@ void zend_do_namespace(znode *name TSRMLS_DC) /* {{{ */ zstr lcname; if (CG(active_op_array)->last > 0) { - zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script"); + /* ignore ZEND_EXT_STMT */ + int num = CG(active_op_array)->last; + while (num > 0 && + CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT) { + --num; + } + if (num > 0) { + zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script"); + } } if (CG(current_namespace)) { zend_error(E_COMPILE_ERROR, "Namespace cannot be declared twice"); |
