mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
Port to GCC 2.95. First two problems reported by Michael Deutschmann in
<http://lists.gnu.org/archive/html/bug-bison/2006-09/msg00018.html>. * src/parse-gram.y (symbol_declaration): Don't put statements before declarations; it's not portable to C89. * src/scan-code.l (handle_action_at): Likewise. * src/scan-code.l: Always initialize braces_level; the old code left it uninitialized and therefore had undefined behavior. Don't attempt to redefine 'assert', since it runs afoul of systems where standard headers (mistakenly) include <assert.h>. Instead, define and use our own alternative, called 'aver'. * src/reader.c: Don't include assert.h, since we no longer use assert. * src/scan-code.l: Likewise. * src/system.h (assert): Remove, replacing with.... (aver): New function, taking a bool arg. All uses changed. * src/tables.c (pack_vector): Ensure that aver arg is bool, not merely an integer.
This commit is contained in:
23
ChangeLog
23
ChangeLog
@@ -1,3 +1,26 @@
|
|||||||
|
2006-09-15 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
Port to GCC 2.95. First two problems reported by Michael Deutschmann in
|
||||||
|
<http://lists.gnu.org/archive/html/bug-bison/2006-09/msg00018.html>.
|
||||||
|
|
||||||
|
* src/parse-gram.y (symbol_declaration): Don't put statements
|
||||||
|
before declarations; it's not portable to C89.
|
||||||
|
* src/scan-code.l (handle_action_at): Likewise.
|
||||||
|
|
||||||
|
* src/scan-code.l: Always initialize braces_level; the old code
|
||||||
|
left it uninitialized and therefore had undefined behavior.
|
||||||
|
|
||||||
|
Don't attempt to redefine 'assert', since it runs afoul of
|
||||||
|
systems where standard headers (mistakenly) include <assert.h>.
|
||||||
|
Instead, define and use our own alternative, called 'aver'.
|
||||||
|
* src/reader.c: Don't include assert.h, since we no longer
|
||||||
|
use assert.
|
||||||
|
* src/scan-code.l: Likewise.
|
||||||
|
* src/system.h (assert): Remove, replacing with....
|
||||||
|
(aver): New function, taking a bool arg. All uses changed.
|
||||||
|
* src/tables.c (pack_vector): Ensure that aver arg is bool,
|
||||||
|
not merely an integer.
|
||||||
|
|
||||||
2006-09-15 Bob Rossi <bob@brasko.net>
|
2006-09-15 Bob Rossi <bob@brasko.net>
|
||||||
|
|
||||||
* data/Makefile.am (dist_pkgdata_DATA): Add push.c.
|
* data/Makefile.am (dist_pkgdata_DATA): Add push.c.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* Generate the nondeterministic finite state machine for Bison.
|
/* Generate the nondeterministic finite state machine for Bison.
|
||||||
|
|
||||||
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005 Free
|
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005, 2006
|
||||||
Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ save_reductions (state *s)
|
|||||||
if (r == 0)
|
if (r == 0)
|
||||||
{
|
{
|
||||||
/* This is "reduce 0", i.e., accept. */
|
/* This is "reduce 0", i.e., accept. */
|
||||||
assert (!final_state);
|
aver (!final_state);
|
||||||
final_state = s;
|
final_state = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ set_goto_map (void)
|
|||||||
ngotos++;
|
ngotos++;
|
||||||
|
|
||||||
/* Abort if (ngotos + 1) would overflow. */
|
/* Abort if (ngotos + 1) would overflow. */
|
||||||
assert (ngotos != GOTO_NUMBER_MAXIMUM);
|
aver (ngotos != GOTO_NUMBER_MAXIMUM);
|
||||||
|
|
||||||
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ map_goto (state_number s0, symbol_number sym)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
assert (low <= high);
|
aver (low <= high);
|
||||||
middle = (low + high) / 2;
|
middle = (low + high) / 2;
|
||||||
s = from_state[middle];
|
s = from_state[middle];
|
||||||
if (s == s0)
|
if (s == s0)
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ nullable_compute (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* This rule has an empty RHS. */
|
/* This rule has an empty RHS. */
|
||||||
assert (item_number_as_rule_number (rules_ruleno->rhs[0])
|
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
|
||||||
== ruleno);
|
== ruleno);
|
||||||
if (rules_ruleno->useful
|
if (rules_ruleno->useful
|
||||||
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ prepare_rules (void)
|
|||||||
/* Merger-function index (GLR). */
|
/* Merger-function index (GLR). */
|
||||||
merger[r] = rules[r].merger;
|
merger[r] = rules[r].merger;
|
||||||
}
|
}
|
||||||
assert (i == nritems);
|
aver (i == nritems);
|
||||||
|
|
||||||
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
|
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
|
||||||
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
|
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
|
||||||
@@ -342,7 +342,7 @@ token_definitions_output (FILE *out)
|
|||||||
/* At this stage, if there are literal aliases, they are part of
|
/* At this stage, if there are literal aliases, they are part of
|
||||||
SYMBOLS, so we should not find symbols which are the aliases
|
SYMBOLS, so we should not find symbols which are the aliases
|
||||||
here. */
|
here. */
|
||||||
assert (number != USER_NUMBER_ALIAS);
|
aver (number != USER_NUMBER_ALIAS);
|
||||||
|
|
||||||
/* Skip error token. */
|
/* Skip error token. */
|
||||||
if (sym == errtoken)
|
if (sym == errtoken)
|
||||||
|
|||||||
@@ -345,8 +345,8 @@ symbol_declaration:
|
|||||||
}
|
}
|
||||||
| "%type" TYPE symbols.1
|
| "%type" TYPE symbols.1
|
||||||
{
|
{
|
||||||
tag_seen = true;
|
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
tag_seen = true;
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_type_set (list->content.sym, $2, @2);
|
symbol_type_set (list->content.sym, $2, @2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
|
|||||||
13
src/reader.c
13
src/reader.c
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
|
|
||||||
@@ -148,7 +147,7 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
|
|||||||
merge_function != NULL && merger_find != merger;
|
merge_function != NULL && merger_find != merger;
|
||||||
merge_function = merge_function->next)
|
merge_function = merge_function->next)
|
||||||
merger_find += 1;
|
merger_find += 1;
|
||||||
assert (merge_function != NULL && merger_find == merger);
|
aver (merge_function != NULL && merger_find == merger);
|
||||||
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||||
{
|
{
|
||||||
complain_at (declaration_loc,
|
complain_at (declaration_loc,
|
||||||
@@ -515,15 +514,15 @@ packgram (void)
|
|||||||
}
|
}
|
||||||
/* An item ends by the rule number (negated). */
|
/* An item ends by the rule number (negated). */
|
||||||
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
||||||
assert (itemno < ITEM_NUMBER_MAX);
|
aver (itemno < ITEM_NUMBER_MAX);
|
||||||
++ruleno;
|
++ruleno;
|
||||||
assert (ruleno < RULE_NUMBER_MAX);
|
aver (ruleno < RULE_NUMBER_MAX);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (itemno == nritems);
|
aver (itemno == nritems);
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
ritem_print (stderr);
|
ritem_print (stderr);
|
||||||
@@ -614,7 +613,7 @@ check_and_convert_grammar (void)
|
|||||||
node = node->next)
|
node = node->next)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
assert (node != NULL);
|
aver (node != NULL);
|
||||||
grammar_start_symbol_set (node->content.sym,
|
grammar_start_symbol_set (node->content.sym,
|
||||||
node->content.sym->location);
|
node->content.sym->location);
|
||||||
}
|
}
|
||||||
@@ -635,7 +634,7 @@ check_and_convert_grammar (void)
|
|||||||
grammar = p;
|
grammar = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars);
|
aver (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars);
|
||||||
|
|
||||||
/* Assign the symbols their symbol numbers. Write #defines for the
|
/* Assign the symbols their symbol numbers. Write #defines for the
|
||||||
token symbols into FDEFINES if requested. */
|
token symbols into FDEFINES if requested. */
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <get-errno.h>
|
#include <get-errno.h>
|
||||||
#include <quote.h>
|
#include <quote.h>
|
||||||
|
|
||||||
@@ -79,14 +78,14 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
/* Nesting level of the current code in braces. */
|
/* Nesting level of the current code in braces. */
|
||||||
int braces_level IF_LINT (= 0);
|
int braces_level = 0;
|
||||||
|
|
||||||
/* This scanner is special: it is invoked only once, henceforth
|
/* This scanner is special: it is invoked only once, henceforth
|
||||||
is expected to return only once. This initialization is
|
is expected to return only once. This initialization is
|
||||||
therefore done once per action to translate. */
|
therefore done once per action to translate. */
|
||||||
assert (sc_context == SC_SYMBOL_ACTION
|
aver (sc_context == SC_SYMBOL_ACTION
|
||||||
|| sc_context == SC_RULE_ACTION
|
|| sc_context == SC_RULE_ACTION
|
||||||
|| sc_context == INITIAL);
|
|| sc_context == INITIAL);
|
||||||
BEGIN sc_context;
|
BEGIN sc_context;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -339,13 +338,12 @@ static void
|
|||||||
handle_action_at (symbol_list *rule, char *text, location at_loc)
|
handle_action_at (symbol_list *rule, char *text, location at_loc)
|
||||||
{
|
{
|
||||||
char *cp = text + 1;
|
char *cp = text + 1;
|
||||||
locations_flag = true;
|
int effective_rule_length =
|
||||||
int effective_rule_length;
|
(rule->midrule_parent_rule
|
||||||
|
? rule->midrule_parent_rhs_index - 1
|
||||||
|
: symbol_list_length (rule->next));
|
||||||
|
|
||||||
if (rule->midrule_parent_rule)
|
locations_flag = true;
|
||||||
effective_rule_length = rule->midrule_parent_rhs_index - 1;
|
|
||||||
else
|
|
||||||
effective_rule_length = symbol_list_length (rule->next);
|
|
||||||
|
|
||||||
if (*cp == '$')
|
if (*cp == '$')
|
||||||
obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
|
obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
|
||||||
|
|||||||
10
src/state.c
10
src/state.c
@@ -61,7 +61,7 @@ transitions_to (transitions *shifts, symbol_number sym)
|
|||||||
int j;
|
int j;
|
||||||
for (j = 0; ; j++)
|
for (j = 0; ; j++)
|
||||||
{
|
{
|
||||||
assert (j < shifts->num);
|
aver (j < shifts->num);
|
||||||
if (TRANSITION_SYMBOL (shifts, j) == sym)
|
if (TRANSITION_SYMBOL (shifts, j) == sym)
|
||||||
return shifts->states[j];
|
return shifts->states[j];
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ state_new (symbol_number accessing_symbol,
|
|||||||
state *res;
|
state *res;
|
||||||
size_t items_size = nitems * sizeof *core;
|
size_t items_size = nitems * sizeof *core;
|
||||||
|
|
||||||
assert (nstates < STATE_NUMBER_MAXIMUM);
|
aver (nstates < STATE_NUMBER_MAXIMUM);
|
||||||
|
|
||||||
res = xmalloc (offsetof (state, items) + items_size);
|
res = xmalloc (offsetof (state, items) + items_size);
|
||||||
res->number = nstates++;
|
res->number = nstates++;
|
||||||
@@ -176,7 +176,7 @@ state_free (state *s)
|
|||||||
void
|
void
|
||||||
state_transitions_set (state *s, int num, state **trans)
|
state_transitions_set (state *s, int num, state **trans)
|
||||||
{
|
{
|
||||||
assert (!s->transitions);
|
aver (!s->transitions);
|
||||||
s->transitions = transitions_new (num, trans);
|
s->transitions = transitions_new (num, trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ state_transitions_set (state *s, int num, state **trans)
|
|||||||
void
|
void
|
||||||
state_reductions_set (state *s, int num, rule **reds)
|
state_reductions_set (state *s, int num, rule **reds)
|
||||||
{
|
{
|
||||||
assert (!s->reductions);
|
aver (!s->reductions);
|
||||||
s->reductions = reductions_new (num, reds);
|
s->reductions = reductions_new (num, reds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ state_reduction_find (state *s, rule *r)
|
|||||||
void
|
void
|
||||||
state_errs_set (state *s, int num, symbol **tokens)
|
state_errs_set (state *s, int num, symbol **tokens)
|
||||||
{
|
{
|
||||||
assert (!s->errs);
|
aver (!s->errs);
|
||||||
s->errs = errs_new (num, tokens);
|
s->errs = errs_new (num, tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ symbol_list_n_type_name_get (symbol_list *l, location loc, int n)
|
|||||||
complain_at (loc, _("invalid $ value: $%d"), n);
|
complain_at (loc, _("invalid $ value: $%d"), n);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert (l->content_type == SYMLIST_SYMBOL);
|
aver (l->content_type == SYMLIST_SYMBOL);
|
||||||
return l->content.sym->type_name;
|
return l->content.sym->type_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
|
|||||||
{
|
{
|
||||||
int *user_token_numberp;
|
int *user_token_numberp;
|
||||||
|
|
||||||
assert (sym->class == token_sym);
|
aver (sym->class == token_sym);
|
||||||
|
|
||||||
if (sym->user_token_number != USER_NUMBER_ALIAS)
|
if (sym->user_token_number != USER_NUMBER_ALIAS)
|
||||||
user_token_numberp = &sym->user_token_number;
|
user_token_numberp = &sym->user_token_number;
|
||||||
@@ -546,7 +546,7 @@ symbol_pack (symbol *this)
|
|||||||
this->number = this->alias->number = 0;
|
this->number = this->alias->number = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert (this->alias->number != NUMBER_UNDEFINED);
|
aver (this->alias->number != NUMBER_UNDEFINED);
|
||||||
this->number = this->alias->number;
|
this->number = this->alias->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,7 +555,7 @@ symbol_pack (symbol *this)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else /* this->class == token_sym */
|
else /* this->class == token_sym */
|
||||||
assert (this->number != NUMBER_UNDEFINED);
|
aver (this->number != NUMBER_UNDEFINED);
|
||||||
|
|
||||||
symbols[this->number] = this;
|
symbols[this->number] = this;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
20
src/system.h
20
src/system.h
@@ -136,6 +136,21 @@ typedef size_t uintptr_t;
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------.
|
||||||
|
| Assertions. |
|
||||||
|
`-------------*/
|
||||||
|
|
||||||
|
/* <assert.h>'s assertions are too heavyweight, and can be disabled
|
||||||
|
too easily, so use aver rather than assert. */
|
||||||
|
static inline void
|
||||||
|
aver (bool assertion)
|
||||||
|
{
|
||||||
|
if (! assertion)
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------.
|
/*-----------.
|
||||||
| Obstacks. |
|
| Obstacks. |
|
||||||
`-----------*/
|
`-----------*/
|
||||||
@@ -210,11 +225,6 @@ do { \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
/* Assertions. <assert.h>'s assertions are too heavyweight, and can
|
|
||||||
be disabled too easily, so implement it separately here. */
|
|
||||||
#define assert(x) ((void) ((x) || (abort (), 0)))
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------.
|
/*---------------------------------------------.
|
||||||
| Debugging memory allocation (must be last). |
|
| Debugging memory allocation (must be last). |
|
||||||
`---------------------------------------------*/
|
`---------------------------------------------*/
|
||||||
|
|||||||
12
src/tables.c
12
src/tables.c
@@ -1,7 +1,7 @@
|
|||||||
/* Output the generated parsing program for Bison.
|
/* Output the generated parsing program for Bison.
|
||||||
|
|
||||||
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
|
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
|
||||||
2005 Free Software Foundation, Inc.
|
2005, 2006 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -202,14 +202,14 @@ conflict_row (state *s)
|
|||||||
&& (actrow[j]
|
&& (actrow[j]
|
||||||
!= rule_number_as_item_number (reds->rules[i]->number)))
|
!= rule_number_as_item_number (reds->rules[i]->number)))
|
||||||
{
|
{
|
||||||
assert (0 < conflict_list_free);
|
aver (0 < conflict_list_free);
|
||||||
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
||||||
conflict_list_cnt += 1;
|
conflict_list_cnt += 1;
|
||||||
conflict_list_free -= 1;
|
conflict_list_free -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Leave a 0 at the end. */
|
/* Leave a 0 at the end. */
|
||||||
assert (0 < conflict_list_free);
|
aver (0 < conflict_list_free);
|
||||||
conflict_list[conflict_list_cnt] = 0;
|
conflict_list[conflict_list_cnt] = 0;
|
||||||
conflict_list_cnt += 1;
|
conflict_list_cnt += 1;
|
||||||
conflict_list_free -= 1;
|
conflict_list_free -= 1;
|
||||||
@@ -673,14 +673,14 @@ pack_vector (vector_number vector)
|
|||||||
base_number *to = tos[i];
|
base_number *to = tos[i];
|
||||||
unsigned int *conflict_to = conflict_tos[i];
|
unsigned int *conflict_to = conflict_tos[i];
|
||||||
|
|
||||||
assert (t);
|
aver (t != 0);
|
||||||
|
|
||||||
for (j = lowzero - from[0]; ; j++)
|
for (j = lowzero - from[0]; ; j++)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
assert (j < table_size);
|
aver (j < table_size);
|
||||||
|
|
||||||
for (k = 0; ok && k < t; k++)
|
for (k = 0; ok && k < t; k++)
|
||||||
{
|
{
|
||||||
@@ -713,7 +713,7 @@ pack_vector (vector_number vector)
|
|||||||
if (loc > high)
|
if (loc > high)
|
||||||
high = loc;
|
high = loc;
|
||||||
|
|
||||||
assert (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user