X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/df222dfaf4da6becae8665d344669eefc705d7f7..02803d55cd78f1fe9516f20efd3f094e35577ddf:/tests/actions.at?ds=sidebyside diff --git a/tests/actions.at b/tests/actions.at index 144791c5..24c6ac8a 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,6 +1,6 @@ # Executing Actions. -*- Autotest -*- -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -# 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 @@ -158,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