Permalink
Browse files

Fix bogus implicit declarations of properties (squash bug #23671)

  • Loading branch information...
1 parent 565985a commit 8d2a4e04aeaded2606ca191af6d61692f320c694 @zsuraski zsuraski committed Jun 9, 2003
Showing with 37 additions and 10 deletions.
  1. +35 −9 Zend/zend_compile.c
  2. +1 −0 Zend/zend_compile.h
  3. +1 −1 Zend/zend_language_parser.y
View
@@ -2516,12 +2516,6 @@ void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS
break;
}
*result = opline_ptr->result;
- if (CG(active_class_entry)
- && property->op_type == IS_CONST
- && !zend_hash_exists(&CG(active_class_entry)->properties_info, property->u.constant.value.str.val, property->u.constant.value.str.len+1)) {
- property->u.constant.value.str.val = estrndup(property->u.constant.value.str.val, property->u.constant.value.str.len);
- zend_do_declare_property(property, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_IMPLICIT_PUBLIC TSRMLS_CC);
- }
return;
}
}
@@ -2539,6 +2533,36 @@ void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS
}
+
+void zend_do_declare_implicit_property(TSRMLS_D)
+{
+ zend_op *opline_ptr;
+ zend_llist_element *le;
+ zend_llist *fetch_list_ptr;
+
+
+ zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
+
+ if (fetch_list_ptr->count != 1) {
+ return;
+ }
+
+ le = fetch_list_ptr->head;
+ opline_ptr = (zend_op *) le->data;
+
+ if (opline_ptr->op1.op_type == IS_UNUSED
+ && CG(active_class_entry)
+ && opline_ptr->op2.op_type == IS_CONST
+ && !zend_hash_exists(&CG(active_class_entry)->properties_info, opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len+1)) {
+ znode property;
+
+ property = opline_ptr->op2;
+ property.u.constant.value.str.val = estrndup(opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len);
+ zend_do_declare_property(&property, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_IMPLICIT_PUBLIC TSRMLS_CC);
+ }
+}
+
+
void zend_do_push_object(znode *object TSRMLS_DC)
{
zend_stack_push(&CG(object_stack), object, sizeof(znode));
@@ -2547,10 +2571,12 @@ void zend_do_push_object(znode *object TSRMLS_DC)
void zend_do_pop_object(znode *object TSRMLS_DC)
{
- znode *tmp;
+ if (object) {
+ znode *tmp;
- zend_stack_top(&CG(object_stack), (void **) &tmp);
- *object = *tmp;
+ zend_stack_top(&CG(object_stack), (void **) &tmp);
+ *object = *tmp;
+ }
zend_stack_del_top(&CG(object_stack));
}
View
@@ -369,6 +369,7 @@ void zend_do_default_before_statement(znode *case_list, znode *default_token TSR
void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znode *parent_class_name TSRMLS_DC);
void zend_do_end_class_declaration(znode *class_token, znode *parent_token TSRMLS_DC);
void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_type TSRMLS_DC);
+void zend_do_declare_implicit_property(TSRMLS_D);
void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC);
void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS_DC);
@@ -746,7 +746,7 @@ method_or_not:
function_call_parameter_list ')'
{ zend_do_end_function_call(&$1, &$$, &$3, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);
zend_do_push_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_METHOD_CALL; }
- | /* empty */ { $$.u.EA.type = ZEND_PARSED_MEMBER; }
+ | /* empty */ { zend_do_declare_implicit_property(TSRMLS_C); $$.u.EA.type = ZEND_PARSED_MEMBER; }
;
variable_without_objects:

0 comments on commit 8d2a4e0

Please sign in to comment.