From: Akim Demaille Date: Tue, 7 May 2002 08:07:32 +0000 (+0000) Subject: Kill GCC warnings. X-Git-Tag: BISON-1_49b~230 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/0c2d3f4cba35c4bbea660794ab3cf91c030aafd3?ds=inline;hp=e41fdc9310174cd2718308bb8fb52d86c479e204 Kill GCC warnings. * src/reduce.c (nonterminals_reduce): Don't loop over RITEM: loop over the RHS of each rule. * src/gram.h, src/gram.c (nritems): Is `unsigned int', not int. * src/state.h (state_t): Member `nitems' is unsigned short. * src/LR0.c (get_state): Adjust. * src/reader.c (packgram): Likewise. * src/output.c (GENERATE_MUSCLE_INSERT_TABLE): `max' is of type `Type'. (muscle_insert_int_table): Remove, unused. (prepare_rules): Remove `max'. --- diff --git a/ChangeLog b/ChangeLog index 8e8530c8..8115de8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-05-07 Akim Demaille + + Kill GCC warnings. + + * src/reduce.c (nonterminals_reduce): Don't loop over RITEM: loop + over the RHS of each rule. + * src/gram.h, src/gram.c (nritems): Is `unsigned int', not int. + * src/state.h (state_t): Member `nitems' is unsigned short. + * src/LR0.c (get_state): Adjust. + * src/reader.c (packgram): Likewise. + * src/output.c (GENERATE_MUSCLE_INSERT_TABLE): `max' is of type + `Type'. + (muscle_insert_int_table): Remove, unused. + (prepare_rules): Remove `max'. + 2002-05-06 Akim Demaille * src/closure.c (print_firsts): Display of the symbol tags. diff --git a/src/LR0.c b/src/LR0.c index 72448d73..fce8b3db 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -231,7 +231,7 @@ static int get_state (token_number_t symbol, size_t core_size, item_number_t *core) { int key; - int i; + size_t i; state_t *sp; if (trace_flag) diff --git a/src/gram.c b/src/gram.c index 3fc03d0e..de5a217c 100644 --- a/src/gram.c +++ b/src/gram.c @@ -29,7 +29,7 @@ /* comments for these variables are in gram.h */ item_number_t *ritem = NULL; -int nritems = 0; +unsigned int nritems = 0; rule_t *rules = NULL; int nrules = 0; @@ -70,7 +70,7 @@ rule_rhs_length (rule_t *rule) void ritem_print (FILE *out) { - int i; + unsigned int i; fputs ("RITEM\n", out); for (i = 0; i < nritems; ++i) if (ritem[i] >= 0) diff --git a/src/gram.h b/src/gram.h index 88946cff..0a92993c 100644 --- a/src/gram.h +++ b/src/gram.h @@ -110,7 +110,7 @@ extern int nvars; #define ITEM_NUMBER_MAX INT_MAX typedef int item_number_t; extern item_number_t *ritem; -extern int nritems; +extern unsigned int nritems; /* There is weird relationship between item_number_t and token_number_t: we store token_number_t in item_number_t, but in diff --git a/src/output.c b/src/output.c index e424143d..cff89a78 100644 --- a/src/output.c +++ b/src/output.c @@ -184,7 +184,7 @@ Name (const char *name, \ int begin, \ int end) \ { \ - long int max = first; \ + Type max = first; \ int i; \ int j = 1; \ \ @@ -209,10 +209,10 @@ Name (const char *name, \ /* Build `NAME_max' in the obstack. */ \ obstack_fgrow1 (&format_obstack, "%s_max", name); \ obstack_1grow (&format_obstack, 0); \ - MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), max); \ + MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), \ + (long int) max); \ } -GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_short_table, short) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_token_number_table, token_number_t) @@ -285,7 +285,6 @@ prepare_tokens (void) static void prepare_rules (void) { - long int max; int r; unsigned int i = 0; item_number_t *rhs = XMALLOC (item_number_t, nritems); diff --git a/src/reader.c b/src/reader.c index f0753460..1aa767fa 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1736,7 +1736,7 @@ packsymbols (void) static void packgram (void) { - int itemno; + unsigned int itemno; int ruleno; symbol_list *p; diff --git a/src/reduce.c b/src/reduce.c index 2d51a24c..fd6f9e15 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -306,11 +306,17 @@ nonterminals_reduce (void) free (symbols_sorted + ntokens); } - for (i = 0; i < nritems; ++i) - if (ISVAR (ritem[i])) - ritem[i] = token_number_as_item_number (nontermmap[ritem[i]]); - - start_symbol = nontermmap[start_symbol]; + { + int r; + for (r = 1; r < nrules + 1; ++r) + { + item_number_t *rhsp; + for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp) + if (ISVAR (*rhsp)) + *rhsp = token_number_as_item_number (nontermmap[*rhsp]); + } + start_symbol = nontermmap[start_symbol]; + } nsyms -= nuseless_nonterminals; nvars -= nuseless_nonterminals; diff --git a/src/state.h b/src/state.h index dc093fea..92378c70 100644 --- a/src/state.h +++ b/src/state.h @@ -185,7 +185,7 @@ typedef struct state_s int nlookaheads; /* Its items. */ - short nitems; + unsigned short nitems; item_number_t items[1]; } state_t;