diff options
| author | Igor Wiedler <igor@wiedler.ch> | 2013-08-25 00:05:55 +0200 |
|---|---|---|
| committer | Igor Wiedler <igor@wiedler.ch> | 2013-08-25 00:05:55 +0200 |
| commit | 115c5ec7269c6dd7dfaeaa853a3a78a075d88e17 (patch) | |
| tree | e7897eba1b09f249727b6c56b4c48b7696cc90b9 /Zend/zend_compile.c | |
| parent | 85d4cfb00ddda70ae2418db283b0f53431ca62a8 (diff) | |
| download | php-git-115c5ec7269c6dd7dfaeaa853a3a78a075d88e17.tar.gz | |
Compile error on const definition conflicting with import
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 6770670d31..29d0760f60 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7251,6 +7251,7 @@ void zend_do_use_const(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */ { zend_op *opline; + zval **ns_name; if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) { zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants"); @@ -7271,6 +7272,19 @@ void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */ *name = tmp; } + /* Constant name must not conflict with import names */ + if (CG(current_import_const) && + zend_hash_find(CG(current_import_const), Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)+1, (void**)&ns_name) == SUCCESS) { + + char *tmp = zend_str_tolower_dup(Z_STRVAL_PP(ns_name), Z_STRLEN_PP(ns_name)); + + if (Z_STRLEN_PP(ns_name) != Z_STRLEN(name->u.constant) || + memcmp(tmp, Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant))) { + zend_error(E_COMPILE_ERROR, "Cannot declare const %s because the name is already in use", Z_STRVAL(name->u.constant)); + } + efree(tmp); + } + opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_DECLARE_CONST; SET_UNUSED(opline->result); |
