pike.git / src / docode.c

version» Context lines:

pike.git/src/docode.c:38:    cleanup_func cleanup;    void *cleanup_arg;    int stack_depth;   };      struct statement_label_name   {    struct statement_label_name *next;    struct pike_string *str;    INT_TYPE line_number; +  int used;   };      struct statement_label   {    struct statement_label *prev;    struct statement_label_name *name;    /* -2 in break_label is used to flag "open" statement_label entries.    * If an open entry is on top of the stack, it's used instead of a    * new one. That's used to associate statement labels to the    * following statement. */
pike.git/src/docode.c:2317:       case F_BREAK:    case F_CONTINUE: {    struct statement_label *label, *p;       if (CAR(n)) {    struct pike_string *name = CAR(n)->u.sval.u.string;    struct statement_label_name *lbl_name;    for (label = current_label; label; label = label->prev)    for (lbl_name = label->name; lbl_name; lbl_name = lbl_name->next) -  if (lbl_name->str == name) +  if (lbl_name->str == name) { +  lbl_name->used = 1;    goto label_found_1; -  +  }    my_yyerror("No surrounding statement labeled %S.", name);    return 0;       label_found_1:    if (n->token == F_CONTINUE && label->continue_label < 0) {    my_yyerror("Cannot continue the non-loop statement on line %ld.",    (long)lbl_name->line_number);    return 0;    }    }
pike.git/src/docode.c:2376:    }       case F_NORMAL_STMT_LABEL:    case F_CUSTOM_STMT_LABEL: {    struct statement_label *label;    struct statement_label_name name;    BLOCK_BEGIN;    PUSH_STATEMENT_LABEL;    name.str = CAR(n)->u.sval.u.string;    name.line_number = n->line_number; +  name.used = 0;       for (label = current_label; label; label = label->prev) {    struct statement_label_name *lbl_name;    for (lbl_name = label->name; lbl_name; lbl_name = lbl_name->next)    if (lbl_name->str == name.str) {    INT_TYPE save_line = c->lex.current_line;    c->lex.current_line = name.line_number;    my_yyerror("Duplicate nested labels, previous one on line %d.",    lbl_name->line_number);    c->lex.current_line = save_line;
pike.git/src/docode.c:2406:    /* The statement we precede has custom label handling; leave    * the statement_label "open" so the statement will use it    * instead of covering it. */    current_label->break_label = -2;    else    current_label->break_label = -1;    }    DO_CODE_BLOCK(CDR(n));    if (!name.next && current_label->emit_break_label)    low_insert_label(current_label->break_label); +  if (!name.used) { +  low_yyreport(REPORT_WARNING, n->current_file, n->line_number, +  parser_system_string, 0, +  "Label %S not used.\n", name.str); +  }    POP_STATEMENT_LABEL;    BLOCK_END;    return 0;    }       case F_RETURN: {    struct statement_label *p;    int in_catch = 0;    do_docode(CAR(n),0);