mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: fix old cast warnings
We still have a few old C casts in lalr1.cc, let's get rid of them. Reported by Frank Heckenbach. Actually, let's monitor all our casts using easy to grep macros. Let's use these macros to use the C++ standard casts when we are in C++. * data/skeletons/c.m4 (b4_cast_define): New. * data/skeletons/glr.c, data/skeletons/glr.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh, * data/skeletons/yacc.c: Use it and/or its casts. * tests/actions.at, tests/cxx-type.at, * tests/glr-regression.at, tests/headers.at, tests/torture.at, * tests/types.at: Use YY_CAST instead of C casts. * configure.ac (warn_cxx): Add -Wold-style-cast. * doc/bison.texi: Disable it.
This commit is contained in:
@@ -166,7 +166,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
[if (res)
|
||||
{
|
||||
AT_VAL.ival = (res - '0') * 10;
|
||||
AT_VAL.fval = (float) (res - '0') / 10.f;
|
||||
AT_VAL.fval = YY_CAST (float, res - '0') / 10.f;
|
||||
}],
|
||||
[30 0.3])
|
||||
|
||||
@@ -197,7 +197,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
["12"],
|
||||
[if (res)
|
||||
{
|
||||
AT_VAL.up = (struct u *) malloc (sizeof *AT_VAL.up);
|
||||
AT_VAL.up = YY_CAST (struct u *, malloc (sizeof *AT_VAL.up));
|
||||
assert (AT_VAL.up);
|
||||
AT_VAL.up->ival = res - '0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user