2 # Copyright (C) 2001-2024 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. Try also with the
19 # 'subdir-object' option enabled.
20 # See also sister test 'lex-line.sh'.
25 cat >> configure.ac
<< 'END'
26 AC_CONFIG_FILES
([sub
/Makefile
])
34 cat > Makefile.am
<< 'END'
35 AM_LFLAGS
= --never-interactive
38 bin_PROGRAMS
= foo bar
41 foo_SOURCES
= zardoz.y
42 bar_SOURCES
= dir
/quux.y
43 ## Avoid spurious failures with Solaris make.
44 zardoz.@OBJEXT@
: zardoz.c
45 bar-quux.@OBJEXT@
: bar-quux.c
48 cat > sub
/Makefile.am
<< 'END'
49 AUTOMAKE_OPTIONS
= subdir-objects
50 AM_LFLAGS
= --never-interactive
52 noinst_PROGRAMS
= foo bar
54 foo_SOURCES
= zardoz.y
55 bar_SOURCES
= dir
/quux.y
56 ## Avoid spurious failures with Solaris make.
57 foo-zardoz.@OBJEXT@
: foo-zardoz.c
58 dir
/quux.@OBJEXT@
: dir
/quux.c
61 cat > zardoz.y
<< 'END'
63 int yylex
() { return 0; }
64 void yyerror
(const char
*s
) {}
75 cp zardoz.y dir
/quux.y
76 cp zardoz.y sub
/zardoz.y
77 cp zardoz.y sub
/dir
/quux.y
79 c_outputs
='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
83 # FIXME: stop disabling the warnings in the 'unsupported' category
84 # FIXME: once the 'subdir-objects' option has been mandatory.
85 $AUTOMAKE -a -Wno-unsupported
87 for vpath
in : false
; do
102 $EGREP 'line|\.y' $c_outputs
104 # Adjusted "#line" should not contain reference to the builddir.
105 grep '#.*line.*build.*\.y' $c_outputs && exit 1
106 # Adjusted "#line" should not contain reference to the absolute
108 $EGREP '#.*line *"?/.*\.y' $c_outputs && exit 1
109 # Adjusted "#line" should not contain reference to the default
110 # output file names, e.g., 'y.tab.c' and 'y.tab.h'.
111 grep '#.*line.*y\.tab\.' $c_outputs && exit 1
112 # Look out for a silly regression.
113 grep "#.*\.y.*\.y" $c_outputs && exit 1
115 grep '#.*line.*"\.\./zardoz\.y"' zardoz.c
116 grep '#.*line.*"\.\./dir/quux\.y"' bar-quux.c
117 grep '#.*line.*"\.\./\.\./sub/zardoz\.y"' sub
/foo-zardoz.c
118 grep '#.*line.*"\.\./\.\./sub/dir/quux\.y"' sub
/dir
/quux.c
120 grep '#.*line.*"zardoz\.y"' zardoz.c
121 grep '#.*line.*"dir/quux\.y"' bar-quux.c
122 grep '#.*line.*"zardoz\.y"' sub
/foo-zardoz.c
123 grep '#.*line.*"dir/quux\.y"' sub
/dir
/quux.c