mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
tests: fix a memory leak
This has been bugging me for while. I was hard to reproduce: it worked only on GNU/Linux, probably because libc++ implements the small string optimization, while libstdc++ did not and actually allocated on the heap for this small string. See https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00110.html. * tests/types.at (api.value.type): Do not provide a semantic value to EOF.
This commit is contained in:
@@ -132,7 +132,8 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
[],
|
||||
['1' '2' { printf ("%2.1f\n", $1 + $2); }],
|
||||
["12"],
|
||||
[AT_VAL = (res - '0') / 10.0],
|
||||
[if (res)
|
||||
AT_VAL = (res - '0') / 10.0],
|
||||
[0.3])
|
||||
|
||||
# A typedef which looks like a Bison keyword, but it's using braces.
|
||||
@@ -141,7 +142,8 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
[%code requires { typedef double variant; }],
|
||||
['1' '2' { printf ("%2.1f\n", $1 + $2); }],
|
||||
["12"],
|
||||
[AT_VAL = (res - '0') / 10.0],
|
||||
[if (res)
|
||||
AT_VAL = (res - '0') / 10.0],
|
||||
[0.3])
|
||||
|
||||
# A user defined struct.
|
||||
@@ -151,8 +153,11 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
['1' '2'
|
||||
{ printf ("%d %2.1f\n", $1.ival + $2.ival, $1.fval + $2.fval); }],
|
||||
["12"],
|
||||
[AT_VAL.ival = (res - '0') * 10;
|
||||
AT_VAL.fval = (res - '0') / 10.f],
|
||||
[if (res)
|
||||
{
|
||||
AT_VAL.ival = (res - '0') * 10;
|
||||
AT_VAL.fval = (res - '0') / 10.f;
|
||||
}],
|
||||
[30 0.3])
|
||||
|
||||
# A user defined struct that uses pointers.
|
||||
@@ -197,7 +202,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
["12"],
|
||||
[if (res == '1')
|
||||
AT_VAL.ival = 10;
|
||||
else
|
||||
else if (res == '2')
|
||||
AT_VAL.fval = .2f],
|
||||
[10 0.2])
|
||||
|
||||
@@ -215,7 +220,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
["12"],
|
||||
[if (res == '1')
|
||||
AT_VAL.ival = 10;
|
||||
else
|
||||
else if (res == '2')
|
||||
AT_VAL.fval = 0.2f],
|
||||
[10 0.2])])
|
||||
|
||||
@@ -251,7 +256,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
["12"],
|
||||
[if (res == '1')
|
||||
AT_VAL.build(10);
|
||||
else
|
||||
else if (res == '2')
|
||||
AT_VAL.build<std::string>("two");],
|
||||
[10, two])])
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user