Branch: Tag:

2013-04-27

2013-04-27 17:16:37 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Fixed low_inherit() updating parent flags.

The PROGRAM_{NEEDS,USES}_PARENT flags could be lost
in pass 2 of the compiler.

Also fixes a related issue when low_inherit() is
called by decode_value().

4580:   #endif       - /* -  * make this program inherit another program -  */ - PMOD_EXPORT void low_inherit(struct program *p, + static void lower_inherit(struct program *p,    struct object *parent,    int parent_identifier,    int parent_offset,
4857:    fun.id_flags |= ID_INHERITED;    add_to_identifier_references(fun);    } + }    -  + /* +  * make this program inherit another program +  */ + PMOD_EXPORT void low_inherit(struct program *p, +  struct object *parent, +  int parent_identifier, +  int parent_offset, +  INT32 flags, +  struct pike_string *name) + { +  lower_inherit(p, parent, parent_identifier, parent_offset, flags, name); +     if (parent_offset) {    if (p->flags & (PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT)) {    /* We'll need the parent pointer as well... */    struct program_state *state = Pike_compiler;    -  while (state && parent_offset--) { +  /* parent offset was increased by 42 by the caller... */ +  parent_offset -= 42; +  +  while (state && state->new_program && parent_offset--) {    state->new_program->flags |= PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT;    state = state->previous;    }