strings now work in switch statements

This commit is contained in:
Bill Currie 2001-11-12 21:13:55 +00:00
parent 50f2d46398
commit dcfea9796e

View file

@ -213,9 +213,9 @@ switch_expr (switch_block_t *switch_block, expr_t *break_label,
for (l = labels; *l; l++) for (l = labels; *l; l++)
num_labels++; num_labels++;
if (options.code.progsversion == PROG_ID_VERSION if (options.code.progsversion == PROG_ID_VERSION
|| (type->type != ev_string || (type != &type_string
&& type->type != ev_float && type != &type_float
&& type->type != ev_integer) && type != &type_integer)
|| num_labels < 8) { || num_labels < 8) {
for (l = labels; *l; l++) { for (l = labels; *l; l++) {
expr_t *cmp = binary_expr (EQ, sw_val, (*l)->value); expr_t *cmp = binary_expr (EQ, sw_val, (*l)->value);
@ -227,8 +227,13 @@ switch_expr (switch_block_t *switch_block, expr_t *break_label,
append_expr (sw, test); append_expr (sw, test);
} }
} else { } else {
expr_t *temp = new_temp_def_expr (type); expr_t *temp;
int op; int op;
if (type == &type_string)
temp = new_temp_def_expr (&type_integer);
else
temp = new_temp_def_expr (type);
qsort (labels, num_labels, sizeof (*labels), label_compare); qsort (labels, num_labels, sizeof (*labels), label_compare);
switch (type->type) { switch (type->type) {
case ev_string: case ev_string: