]> git.saurik.com Git - bison.git/blame - tests/push.at
* data/yacc.c (yyexhaustedlab): Define it when YYERROR_VERBOSE is
[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{
55 yypstate *yyps;
56 YYSTYPE yylval;
57
58 /* Make sure we don't try to free yyps->yyss in this case. */
59 yyps = yypstate_new ();
60 yypstate_delete (yyps);
61
62 /* yypstate_delete used to leak yyps->yyss if the stack was reallocated but
63 the parse did not return on success, syntax error, or memory
64 exhaustion. */
65 yyps = yypstate_new ();
66 assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE);
67 yypstate_delete (yyps);
68
69 yyps = yypstate_new ();
70 assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE);
71 assert (yypush_parse (yyps, 'b', &yylval) == YYPUSH_MORE);
72 yypstate_delete (yyps);
73
74 return 0;
75}
76]])
77
78AT_CHECK([[bison -o input.c input.y]])
79AT_COMPILE([[input]])
80AT_PARSER_CHECK([[./input]])
81
82AT_CLEANUP