X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/6e30ede87a1c39c53842a6a747ecd9f7484d92a5..eb8c66bbda06f71d107e2780503f2de9ba814ddd:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index 5082da7b..37616506 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,7 +1,6 @@ # Executing Actions. -*- Autotest -*- -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, -# 2010 Free Software Foundation, Inc. +# Copyright (C) 2001-2011 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -159,6 +158,52 @@ AT_PARSER_CHECK([./input], 0, [[15 ]]) +# Make sure that fields after $n or $-n are parsed correctly. At one +# point while implementing dashes in symbol names, we were dropping +# fields after $-n. +AT_DATA_GRAMMAR([[input.y]], +[[ +%{ +# include + static int yylex (void); + static void yyerror (char const *msg); + typedef struct { int val; } stype; +# define YYSTYPE stype +%} + +%% +start: one two { $$.val = $1.val + $2.val; } sum ; +one: { $$.val = 1; } ; +two: { $$.val = 2; } ; +sum: { printf ("%d\n", $0.val + $-1.val + $-2.val); } ; + +%% + +static int +yylex (void) +{ + return 0; +} + +static void +yyerror (char const *msg) +{ + fprintf (stderr, "%s\n", msg); +} + +int +main (void) +{ + return yyparse (); +} +]]) + +AT_BISON_CHECK([[-o input.c input.y]]) +AT_COMPILE([[input]]) +AT_PARSER_CHECK([[./input]], [[0]], +[[6 +]]) + AT_CLEANUP