mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
tests: enable -Wsign-compare and fix corresponding warnings
-Wsign-compare was disabled for bison's own code, following gnulib's approach. However, the generated parsers should not trigger such warnings. Reported by Efi Fogel. http://lists.gnu.org/archive/html/help-bison/2013-04/msg00018.html See also http://stackoverflow.com/questions/16101062 for the weird "-(unsigned)i" piece of code. * configure.ac (warn_tests): Enable -Wsign-compare. * data/location.cc (position::add_): New. (position::lines, position::columns): Use it. * tests/actions.at (AT_CHECK_PRINTER_AND_DESTRUCTOR): Fix signedness issues.
This commit is contained in:
@@ -55,20 +55,14 @@ m4_define([b4_position_define],
|
||||
if (count)
|
||||
{
|
||||
column = ]b4_location_initial_column[u;
|
||||
line =
|
||||
0 < count || -count < line
|
||||
? line + count
|
||||
: ]b4_location_initial_line[;
|
||||
line = add_ (line, count, ]b4_location_initial_line[);
|
||||
}
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (int count = 1)
|
||||
{
|
||||
column =
|
||||
0 < count || -count < column
|
||||
? column + count
|
||||
: ]b4_location_initial_column[;
|
||||
column = add_ (column, count, ]b4_location_initial_column[);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
@@ -78,6 +72,15 @@ m4_define([b4_position_define],
|
||||
unsigned int line;
|
||||
/// Current column number.
|
||||
unsigned int column;
|
||||
|
||||
private:
|
||||
/// Compute max(min, lhs+rhs) (provided min <= lhs).
|
||||
static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
|
||||
{
|
||||
return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
|
||||
? rhs + lhs
|
||||
: min);
|
||||
}
|
||||
};
|
||||
|
||||
/// Add and assign a position.
|
||||
|
||||
Reference in New Issue
Block a user