From: Nikita Popov Date: Sat, 12 Jul 2014 15:10:10 +0000 (+0200) Subject: approx correct linenos in errors X-Git-Tag: POST_AST_MERGE^2~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=069da161cfb6328b512ee07d0c71b8348f54cf96;p=php approx correct linenos in errors --- diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index a1ebf7727d..5ef590d2e7 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -48,19 +48,27 @@ ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) static zend_ast *zend_ast_create_from_va_list( zend_uint children, zend_ast_kind kind, zend_ast_attr attr, va_list va ) { - TSRMLS_FETCH(); + /*TSRMLS_FETCH();*/ zend_uint i; - - zend_ast *ast = emalloc(sizeof(zend_ast) + (children - 1) * sizeof(zend_ast *)); + zend_ast *ast; + + ast = emalloc(sizeof(zend_ast) + (children - 1) * sizeof(zend_ast *)); ast->kind = kind; ast->attr = attr; - ast->lineno = CG(zend_lineno); + ast->lineno = 0; ast->children = children; for (i = 0; i < children; ++i) { ast->child[i] = va_arg(va, zend_ast *); + if (ast->lineno == 0 && ast->child[i] != NULL) { + ast->lineno = ast->child[i]->lineno; + } } + /*if (ast->lineno == 0) { + ast->lineno = CG(zend_lineno); + }*/ + return ast; } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 4f190d764a..b1e5a8c617 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8310,7 +8310,8 @@ void zend_compile_stmt(zend_ast *ast TSRMLS_DC) { } // TODO.AST - //CG(zend_lineno) = ast->lineno; + zend_uint orig_lineno = CG(zend_lineno); + CG(zend_lineno) = ast->lineno; switch (ast->kind) { case ZEND_AST_STMT_LIST: @@ -8376,6 +8377,8 @@ void zend_compile_stmt(zend_ast *ast TSRMLS_DC) { if (Z_LVAL(CG(declarables).ticks) && !zend_is_unticked_stmt(ast)) { zend_emit_tick(TSRMLS_C); } + + CG(zend_lineno) = orig_lineno; } void zend_compile_expr(znode *result, zend_ast *ast TSRMLS_DC) {