Branch: Tag:

2014-09-30

2014-09-30 15:52:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Optimizer: Fixed over-optimization of F_ASSIGN_SELF nodes.

F_ASSIGN_SELF nodes weren't marked as OPT_ASSIGNMENT, so they
could sometimes be removed by the optimizer.

Also fixes some related optimizer and type-checker issues.

Thanks to Chris Angelico <rosuav@gmail.com> for the report.

Fixes [LysLysKOM 20983743].

921:    case F_APPEND_ARRAY:    case F_MULTI_ASSIGN:    case F_ASSIGN: +  case F_ASSIGN_SELF:    res->node_info |= OPT_ASSIGNMENT;    if (a) {    res->tree_info |= a->tree_info;
2187:    low_print_tree(_CAR(foo),0);    break;    +  case F_ASSIGN_SELF: +  low_print_tree(_CDR(foo),1); +  fputc(':', stderr); +  fputc('=', stderr); +  low_print_tree(_CAR(foo),0); +  break; +     case F_POP_VALUE:    fputc('{', stderr);    low_print_tree(_CAR(foo), 0);
2603:    break;       case F_ASSIGN: +  case F_ASSIGN_SELF:    find_used_variables(CAR(n),p,noblock,0);    find_used_variables(CDR(n),p,noblock,1);    break;
2727:    break;       case F_ASSIGN: +  case F_ASSIGN_SELF:    case F_MULTI_ASSIGN:    find_written_vars(CAR(n), p, 0);    find_written_vars(CDR(n), p, 1);
3209:    break;       case F_ASSIGN: +  case F_ASSIGN_SELF:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("Assigning a void expression.");    copy_pike_type(n->type, void_type_string);
3952: Inside #if defined(SHARED_NODES) && 0
      switch(n->token) {    case F_ASSIGN: +  case F_ASSIGN_SELF:    if ((CDR(n)->token == F_LOCAL) && (!CDR(n)->u.integer.b)) {    usage[CDR(n)->u.integer.a] = 0;    } else if (CDR(n)->token == F_ARRAY_LVALUE) {
4220: Inside #if defined(SHARED_NODES) && 0
   switch(n->token) {    /* FIXME: Does not support F_LOOP yet. */    case F_ASSIGN: +  case F_ASSIGN_SELF:    if ((CDR(n)->token == F_LOCAL) && (!CDR(n)->u.integer.b)) {    /* Assignment of local variable */    if (!(usage[CDR(n)->u.integer.a] & 1)) {
4243: Inside #if defined(SHARED_NODES) && 0
   cdr = CDR(n);    ADD_NODE_REF(cdr);    } -  return mknode(F_ASSIGN, low_localopt(CAR(n), usage, switch_u, cont_u, +  return mknode(n->token, low_localopt(CAR(n), usage, switch_u, cont_u,    break_u, catch_u), cdr);       case F_SSCANF: