<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 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>
* data/Makefile.am (dist_pkgdata_DATA): Add push.c.
/* Generate the nondeterministic finite state machine for Bison.
- Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005 Free
- Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
if (r == 0)
{
/* This is "reduce 0", i.e., accept. */
- assert (!final_state);
+ aver (!final_state);
final_state = s;
}
}
ngotos++;
/* Abort if (ngotos + 1) would overflow. */
- assert (ngotos != GOTO_NUMBER_MAXIMUM);
+ aver (ngotos != GOTO_NUMBER_MAXIMUM);
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
for (;;)
{
- assert (low <= high);
+ aver (low <= high);
middle = (low + high) / 2;
s = from_state[middle];
if (s == s0)
else
{
/* This rule has an empty RHS. */
- assert (item_number_as_rule_number (rules_ruleno->rhs[0])
- == ruleno);
+ aver (item_number_as_rule_number (rules_ruleno->rhs[0])
+ == ruleno);
if (rules_ruleno->useful
&& ! nullable[rules_ruleno->lhs->number - ntokens])
{
/* Merger-function index (GLR). */
merger[r] = rules[r].merger;
}
- assert (i == nritems);
+ aver (i == nritems);
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
/* At this stage, if there are literal aliases, they are part of
SYMBOLS, so we should not find symbols which are the aliases
here. */
- assert (number != USER_NUMBER_ALIAS);
+ aver (number != USER_NUMBER_ALIAS);
/* Skip error token. */
if (sym == errtoken)
}
| "%type" TYPE symbols.1
{
- tag_seen = true;
symbol_list *list;
+ tag_seen = true;
for (list = $3; list; list = list->next)
symbol_type_set (list->content.sym, $2, @2);
symbol_list_free ($3);
#include <config.h>
#include "system.h"
-#include <assert.h>
#include <quotearg.h>
merge_function != NULL && merger_find != merger;
merge_function = merge_function->next)
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))
{
complain_at (declaration_loc,
}
/* An item ends by the rule number (negated). */
ritem[itemno++] = rule_number_as_item_number (ruleno);
- assert (itemno < ITEM_NUMBER_MAX);
+ aver (itemno < ITEM_NUMBER_MAX);
++ruleno;
- assert (ruleno < RULE_NUMBER_MAX);
+ aver (ruleno < RULE_NUMBER_MAX);
if (p)
p = p->next;
}
- assert (itemno == nritems);
+ aver (itemno == nritems);
if (trace_flag & trace_sets)
ritem_print (stderr);
node = node->next)
;
}
- assert (node != NULL);
+ aver (node != NULL);
grammar_start_symbol_set (node->content.sym,
node->content.sym->location);
}
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
token symbols into FDEFINES if requested. */
#include "complain.h"
#include "reader.h"
#include "getargs.h"
-#include <assert.h>
#include <get-errno.h>
#include <quote.h>
%{
/* 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
is expected to return only once. This initialization is
therefore done once per action to translate. */
- assert (sc_context == SC_SYMBOL_ACTION
- || sc_context == SC_RULE_ACTION
- || sc_context == INITIAL);
+ aver (sc_context == SC_SYMBOL_ACTION
+ || sc_context == SC_RULE_ACTION
+ || sc_context == INITIAL);
BEGIN sc_context;
%}
handle_action_at (symbol_list *rule, char *text, location at_loc)
{
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)
- effective_rule_length = rule->midrule_parent_rhs_index - 1;
- else
- effective_rule_length = symbol_list_length (rule->next);
+ locations_flag = true;
if (*cp == '$')
obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
int j;
for (j = 0; ; j++)
{
- assert (j < shifts->num);
+ aver (j < shifts->num);
if (TRANSITION_SYMBOL (shifts, j) == sym)
return shifts->states[j];
}
state *res;
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->number = nstates++;
void
state_transitions_set (state *s, int num, state **trans)
{
- assert (!s->transitions);
+ aver (!s->transitions);
s->transitions = transitions_new (num, trans);
}
void
state_reductions_set (state *s, int num, rule **reds)
{
- assert (!s->reductions);
+ aver (!s->reductions);
s->reductions = reductions_new (num, reds);
}
void
state_errs_set (state *s, int num, symbol **tokens)
{
- assert (!s->errs);
+ aver (!s->errs);
s->errs = errs_new (num, tokens);
}
complain_at (loc, _("invalid $ value: $%d"), n);
return NULL;
}
- assert (l->content_type == SYMLIST_SYMBOL);
+ aver (l->content_type == SYMLIST_SYMBOL);
return l->content.sym->type_name;
}
{
int *user_token_numberp;
- assert (sym->class == token_sym);
+ aver (sym->class == token_sym);
if (sym->user_token_number != USER_NUMBER_ALIAS)
user_token_numberp = &sym->user_token_number;
this->number = this->alias->number = 0;
else
{
- assert (this->alias->number != NUMBER_UNDEFINED);
+ aver (this->alias->number != NUMBER_UNDEFINED);
this->number = this->alias->number;
}
}
return true;
}
else /* this->class == token_sym */
- assert (this->number != NUMBER_UNDEFINED);
+ aver (this->number != NUMBER_UNDEFINED);
symbols[this->number] = this;
return true;
#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. |
`-----------*/
} 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). |
`---------------------------------------------*/
/* Output the generated parsing program for Bison.
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.
&& (actrow[j]
!= 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_cnt += 1;
conflict_list_free -= 1;
}
/* Leave a 0 at the end. */
- assert (0 < conflict_list_free);
+ aver (0 < conflict_list_free);
conflict_list[conflict_list_cnt] = 0;
conflict_list_cnt += 1;
conflict_list_free -= 1;
base_number *to = tos[i];
unsigned int *conflict_to = conflict_tos[i];
- assert (t);
+ aver (t != 0);
for (j = lowzero - from[0]; ; j++)
{
int k;
bool ok = true;
- assert (j < table_size);
+ aver (j < table_size);
for (k = 0; ok && k < t; k++)
{
if (loc > high)
high = loc;
- assert (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
+ aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
return j;
}
}