* lib/abitset.c (abitset_test): Remove ATTRIBUTE_UNUSED; not needed.
* lib/bitset.c (bitset_bytes, bitset_init, bitset_op4_cmp):
Put 'default: abort ();' before some other case, to satisfy older
pedantic compilers.
* lib/bitset_stats.c (bitset_stats_init): Likewise.
* lib/ebitset.c (ebitset_elt_find, ebitset_op3_cmp): Likewise.
* lib/lbitset.c (lbitset_elt_find, lbitset_op3_cmp): Likewise.
* src/conflicts.c (resolve_sr_conflict): Likewise.
* src/vcg.c (get_color_str, get_textmode_str, get_shape_str):
(get_decision_str, get_orientation_str, get_node_alignment_str):
(get_arrow_mode_str, get_crossing_type_str, get_view_str):
(get_linestyle_str, get_arrowstyle_str): Likewise.
* src/conflicts.c (resolve_sr_conflict):
Use a default case rather than one for the one remaining enum
value, to catch invalid enum values as well.
* src/lalr.c (set_goto_map, map_goto):
Prefer "assert (FOO);" to "if (!FOO) abort ();".
* src/nullable.c (nullable_compute, token_definitions_output):
Likewise.
* src/reader.c (packgram, reader): Likewise.
* src/state.c (transitions_to, state_new, state_reduction_find):
Likewise.
* src/symtab.c (symbol_user_token_number_set, symbol_make_alias):
(symbol_pack): Likewise.
* src/tables.c (conflict_row, pack_vector): Likewise.
* src/scan-skel.l (QPUTS): Remove unnecessary parens.
(BASE_QPUTS, "@output ".*\n): Remove unnecessary asserts.
* src/system.h: Don't include <assert.h>.
(assert): New macro.
2006-01-20 Paul Eggert <eggert@cs.ucla.edu>
- * doc/bison.texinfo (Prologue, Rules, Actions, Union Decl, Action Decl):
- (Destructor Decl, Parser Function, Pure Calling):
- Describe rules for braces inside C code more carefully.
-
Be a bit more systematic about using 'abort'.
* lib/abitset.c (abitset_test): Remove ATTRIBUTE_UNUSED; not needed.
* lib/bitset.c (bitset_bytes, bitset_init, bitset_op4_cmp):
* lib/ebitset.c (ebitset_elt_find, ebitset_op3_cmp): Likewise.
* lib/lbitset.c (lbitset_elt_find, lbitset_op3_cmp): Likewise.
* src/conflicts.c (resolve_sr_conflict): Likewise.
- * src/LR0.c (save_reductions): Use "if (!FOO) abort ();" rather than
- "assert (FOO);".
- * src/state.c (state_transitions_set, state_reductions_set): Likewise.
+ * src/vcg.c (get_color_str, get_textmode_str, get_shape_str):
+ (get_decision_str, get_orientation_str, get_node_alignment_str):
+ (get_arrow_mode_str, get_crossing_type_str, get_view_str):
+ (get_linestyle_str, get_arrowstyle_str): Likewise.
+ * src/conflicts.c (resolve_sr_conflict):
+ Use a default case rather than one for the one remaining enum
+ value, to catch invalid enum values as well.
+ * src/lalr.c (set_goto_map, map_goto):
+ Prefer "assert (FOO);" to "if (!FOO) abort ();".
+ * src/nullable.c (nullable_compute, token_definitions_output):
+ Likewise.
+ * src/reader.c (packgram, reader): Likewise.
+ * src/state.c (transitions_to, state_new, state_reduction_find):
+ Likewise.
+ * src/symtab.c (symbol_user_token_number_set, symbol_make_alias):
+ (symbol_pack): Likewise.
+ * src/tables.c (conflict_row, pack_vector): Likewise.
* src/scan-skel.l (QPUTS): Remove unnecessary parens.
(BASE_QPUTS, "@output ".*\n): Remove unnecessary asserts.
+ * src/system.h: Don't include <assert.h>.
+ (assert): New macro.
+
+ * doc/bison.texinfo (Prologue, Rules, Actions, Union Decl, Action Decl):
+ (Destructor Decl, Parser Function, Pure Calling):
+ Describe rules for braces inside C code more carefully.
2006-01-19 Paul Eggert <eggert@cs.ucla.edu>
static bitset_bindex
-abitset_resize (bitset src ATTRIBUTE_UNUSED,
- bitset_bindex size ATTRIBUTE_UNUSED)
+abitset_resize (bitset src, bitset_bindex size)
{
/* These bitsets have a fixed size. */
if (BITSET_SIZE_ (src) != size)
/* General bitsets.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
switch (type)
{
+ default:
+ abort ();
+
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
break;
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
break;
-
- default:
- abort ();
}
return bytes;
switch (type)
{
+ default:
+ abort ();
+
case BITSET_ARRAY:
return abitset_init (bset, n_bits);
case BITSET_VARRAY:
return vbitset_init (bset, n_bits);
-
- default:
- abort ();
}
}
switch (op)
{
+ default:
+ abort ();
+
case BITSET_OP_OR_AND:
bitset_or (tmp, src1, src2);
changed = bitset_and_cmp (dst, src3, tmp);
bitset_andn (tmp, src1, src2);
changed = bitset_or_cmp (dst, src3, tmp);
break;
-
- default:
- abort ();
}
bitset_free (tmp);
/* Bitset statistics.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
we are a wrapper over. */
switch (type)
{
+ default:
+ abort ();
+
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
sbset = xcalloc (1, bytes);
sbset = xcalloc (1, bytes);
vbitset_init (sbset, n_bits);
break;
-
- default:
- abort ();
}
bset->s.bset = sbset;
/* Functions to support expandable bitsets.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
switch (mode)
{
+ default:
+ abort ();
+
case EBITSET_FIND:
return 0;
case EBITSET_SUBST:
return &ebitset_zero_elts[0];
-
- default:
- abort ();
}
}
dstp = EBITSET_WORDS (delt);
switch (op)
{
+ default:
+ abort ();
+
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
}
}
break;
-
- default:
- abort ();
}
if (!ebitset_elt_zero_p (delt))
/* Functions to support link list bitsets.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
switch (mode)
{
+ default:
+ abort ();
+
case LBITSET_FIND:
return 0;
case LBITSET_SUBST:
return &lbitset_zero_elts[0];
-
- default:
- abort ();
}
}
dstp = dtmp->words;
switch (op)
{
+ default:
+ abort ();
+
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
}
}
break;
-
- default:
- abort ();
}
if (!lbitset_elt_zero_p (dtmp))
/* Find and resolve or report look-ahead conflicts for bison,
- Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
switch (symbols[i]->assoc)
{
+ default:
+ abort ();
+
case right_assoc:
log_resolution (redrule, i, right_resolution);
flush_reduce (look_ahead_tokens, i);
/* Record an explicit error for this token. */
errors[nerrs++] = symbols[i];
break;
-
- case undef_assoc:
- abort ();
}
}
ngotos++;
/* Abort if (ngotos + 1) would overflow. */
- if (ngotos == GOTO_NUMBER_MAXIMUM)
- abort ();
+ assert (ngotos != GOTO_NUMBER_MAXIMUM);
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
for (;;)
{
- if (high < low)
- abort ();
+ assert (low <= high);
middle = (low + high) / 2;
s = from_state[middle];
if (s == s0)
/* Calculate which nonterminals can expand into the null string for Bison.
- Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004, 2005 Free
- Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
else
{
/* This rule has an empty RHS. */
- if (item_number_as_rule_number (rules_ruleno->rhs[0]) != ruleno)
- abort ();
+ assert (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;
}
- if (i != nritems)
- abort ();
+ assert (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. */
- if (number == USER_NUMBER_ALIAS)
- abort ();
+ assert (number != USER_NUMBER_ALIAS);
/* Skip error token. */
if (sym == errtoken)
p = p->next;
}
- if (itemno != nritems)
- abort ();
+ assert (itemno == nritems);
if (trace_flag & trace_sets)
ritem_print (stderr);
grammar = p;
}
- if (! (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars))
- abort ();
+ assert (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars);
xfclose (gram_in);
/* Scan Bison Skeletons. -*- C -*-
- Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
#include "scan-skel.h"
#define QPUTS(String) \
- fputs (quotearg_style (c_quoting_style, (String)), yyout)
+ fputs (quotearg_style (c_quoting_style, String), yyout)
#define BASE_QPUTS(File) \
- assert (File), QPUTS (base_name (File))
+ QPUTS (base_name (File))
%}
%%
if (*file_name == '@')
{
if (strcmp (file_name, "@output_header_name@") == 0)
- {
- assert (spec_defines_file);
- file_name = spec_defines_file;
- }
+ file_name = spec_defines_file;
else if (strcmp (file_name, "@output_parser_name@") == 0)
- {
- assert (parser_file_name);
- file_name = parser_file_name;
- }
+ file_name = parser_file_name;
else
fatal ("invalid token in skeleton: %s", yytext);
}
int j;
for (j = 0; ; j++)
{
- if (shifts->num <= j)
- abort ();
+ assert (j < shifts->num);
if (TRANSITION_SYMBOL (shifts, j) == sym)
return shifts->states[j];
}
state *res;
size_t items_size = nitems * sizeof *core;
- if (STATE_NUMBER_MAXIMUM <= nstates)
- abort ();
+ assert (nstates < STATE_NUMBER_MAXIMUM);
res = xmalloc (offsetof (state, items) + items_size);
res->number = nstates++;
void
state_errs_set (state *s, int num, symbol **tokens)
{
- if (s->errs)
- abort ();
+ assert (!s->errs);
s->errs = errs_new (num, tokens);
}
void
symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
- if (sym->class != token_sym)
- abort ();
+ assert (sym->class == token_sym);
if (sym->user_token_number != USER_NUMBER_UNDEFINED
&& sym->user_token_number != user_token_number)
/* sym and symval combined are only one symbol. */
nsyms--;
ntokens--;
- if (ntokens != sym->number && ntokens != symval->number)
- abort ();
+ assert (ntokens == sym->number || ntokens == symval->number);
sym->number = symval->number =
(symval->number < sym->number) ? symval->number : sym->number;
symbol_type_set (symval, sym->type_name, loc);
this->number = this->alias->number = 0;
else
{
- if (this->alias->number == NUMBER_UNDEFINED)
- abort ();
+ assert (this->alias->number != NUMBER_UNDEFINED);
this->number = this->alias->number;
}
}
return true;
}
else /* this->class == token_sym */
- {
- if (this->number == NUMBER_UNDEFINED)
- abort ();
- }
+ assert (this->number != NUMBER_UNDEFINED);
symbols[this->number] = this;
return true;
typedef size_t uintptr_t;
#endif
-#include <assert.h>
-
#include <verify.h>
#include <xalloc.h>
} 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). |
`---------------------------------------------*/
&& (actrow[j]
!= rule_number_as_item_number (reds->rules[i]->number)))
{
- if (conflict_list_free <= 0)
- abort ();
+ assert (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. */
- if (conflict_list_free <= 0)
- abort ();
+ assert (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];
- if (!t)
- abort ();
+ assert (t);
for (j = lowzero - from[0]; ; j++)
{
int k;
bool ok = true;
- if (table_size <= j)
- abort ();
+ assert (j < table_size);
for (k = 0; ok && k < t; k++)
{
if (loc > high)
high = loc;
- if (! (BASE_MINIMUM <= j && j <= BASE_MAXIMUM))
- abort ();
+ assert (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
return j;
}
}
/* VCG description handler for Bison.
- Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
{
switch (color)
{
+ default: abort ();
case white: return "white";
case blue: return "blue";
case red: return "red";
case orange: return "orange";
case orchid: return "orchid";
case black: return "black";
- default: abort (); return NULL;
}
}
{
switch (textmode)
{
+ default: abort ();
case centered: return "center";
case left_justify: return "left_justify";
case right_justify: return "right_justify";
- default: abort (); return NULL;
}
}
{
switch (shape)
{
+ default: abort ();
case box: return "box";
case rhomb: return "rhomb";
case ellipse: return "ellipse";
case triangle: return "triangle";
- default: abort (); return NULL;
}
}
{
switch (decision)
{
+ default: abort ();
case no: return "no";
case yes: return "yes";
- default: abort (); return NULL;
}
}
{
switch (orientation)
{
+ default: abort ();
case top_to_bottom: return "top_to_bottom";
case bottom_to_top: return "bottom_to_top";
case left_to_right: return "left_to_right";
case right_to_left: return "right_to_left";
- default: abort (); return NULL;
}
}
{
switch (alignment)
{
+ default: abort ();
case center: return "center";
case top: return "top";
case bottom: return "bottom";
- default: abort (); return NULL;
}
}
{
switch (arrow_mode)
{
+ default: abort ();
case fixed: return "fixed";
case free_a: return "free";
- default: abort (); return NULL;
}
}
{
switch (crossing_type)
{
+ default: abort ();
case bary: return "bary";
case median: return "median";
case barymedian: return "barymedian";
case medianbary: return "medianbary";
- default: abort (); return NULL;
}
}
so it is an error here if view == normal_view. */
switch (view)
{
+ default: abort ();
case cfish: return "cfish";
case pfish: return "pfish";
case fcfish: return "fcfish";
case fpfish: return "fpfish";
- default: abort (); return NULL;
}
}
{
switch (linestyle)
{
+ default: abort ();
case continuous: return "continuous";
case dashed: return "dashed";
case dotted: return "dotted";
case invisible: return "invisible";
- default: abort (); return NULL;
}
}
{
switch (arrowstyle)
{
+ default: abort ();
case solid: return "solid";
case line: return "line";
case none: return "none";
- default: abort (); return NULL;
}
}