]> git.saurik.com Git - bison.git/blame - tests/push.at
Get rid of broken %no-parser, -n, and --no-parser implementation and
[bison.git] / tests / push.at
CommitLineData
eb1b0740
JD
1# Checking Push Parsing. -*- Autotest -*-
2# Copyright (C) 2007 Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17# 02110-1301, USA.
18
19AT_BANNER([[Push Parsing Tests]])
20
21## ---------------------------------------------- ##
22## Push Parsing: Memory Leak for Early Deletion. ##
23## ---------------------------------------------- ##
24
25AT_SETUP([[Push Parsing: Memory Leak for Early Deletion]])
26
27# Requires Valgrind.
28
29AT_DATA_GRAMMAR([[input.y]],
30[[
31%{
32 #include <assert.h>
33 #include <stdio.h>
34 #define YYINITDEPTH 1
35 void yyerror (char const *msg);
36%}
37
38%pure-parser %push-parser
39
40%%
41
42start: 'a' 'b' 'c' ;
43
44%%
45
46void
47yyerror (char const *msg)
48{
49 fprintf (stderr, "%s\n", msg);
50}
51
52int
53main (void)
54{
5d31a216
JD
55 yypstate *ps;
56
57 /* Make sure we don't try to free ps->yyss in this case. */
58 ps = yypstate_new ();
59 yypstate_delete (ps);
60
61 /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
62 parse did not return on success, syntax error, or memory exhaustion. */
63 ps = yypstate_new ();
64 assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
65 yypstate_delete (ps);
66
67 ps = yypstate_new ();
68 assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
69 assert (yypush_parse (ps, 'b', NULL) == YYPUSH_MORE);
70 yypstate_delete (ps);
eb1b0740
JD
71
72 return 0;
73}
74]])
75
76AT_CHECK([[bison -o input.c input.y]])
77AT_COMPILE([[input]])
78AT_PARSER_CHECK([[./input]])
79
80AT_CLEANUP