2 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
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)
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that automake yacc support ensures that yacc-generated C
18 # files use correct "#line" directives.
19 # See also sister test 'lex-line.test'.
24 cat >> configure.ac
<< 'END'
32 cat > Makefile.am
<< 'END'
33 noinst_PROGRAMS
= foo bar baz
35 foo_SOURCES
= zardoz.y
36 bar_SOURCES
= dir
/quux.y
37 baz_SOURCES
= zardoz.y
40 cat > zardoz.y
<< 'END'
42 int yylex
() { return 0; }
43 void yyerror
(char
*s
) { return; }
54 cp zardoz.y dir
/quux.y
56 c_outputs
='zardoz.c dir/quux.c baz-zardoz.c'
60 # FIXME: stop disabling the warnings in the 'unsupported' category
61 # FIXME: once the 'subdir-objects' option has been mandatory.
62 $AUTOMAKE -a -Wno-unsupported
64 for vpath
in : false
; do
79 $EGREP 'line|\.y' $c_outputs
81 # Adjusted "#line" should not contain reference to the builddir.
82 grep '#.*line.*build.*\.y' $c_outputs && exit 1
83 # Adjusted "#line" should not contain reference to the absolute
85 $EGREP '#.*line *"?/.*\.y' $c_outputs && exit 1
86 # Adjusted "#line" should not contain reference to the default
87 # output file names, e.g., 'y.tab.c' and 'y.tab.h'.
88 grep '#.*line.*y\.tab\.' $c_outputs && exit 1
89 # Look out for a silly regression.
90 grep "#.*\.y.*\.y" $c_outputs && exit 1
92 grep '#.*line.*"\.\./zardoz\.y"' zardoz.c
93 grep '#.*line.*"\.\./zardoz\.y"' baz-zardoz.c
94 grep '#.*line.*"\.\./dir/quux\.y"' dir
/quux.c
96 grep '#.*line.*"zardoz\.y"' zardoz.c
97 grep '#.*line.*"zardoz\.y"' baz-zardoz.c
98 grep '#.*line.*"dir/quux\.y"' dir
/quux.c