2 # Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>.
17 # Basic semantic checks on Yacc + C++ support (when yacc-generated
18 # headers are not involved).
19 # Keep in sync with sister test 'yacc-basic.test'.
24 cat >> configure.ac << 'END'
30 cat > Makefile.am << 'END'
31 bin_PROGRAMS = foo1 foo2 foo3 foo4
32 foo1_SOURCES = parse1.yy foo.cc
33 foo2_SOURCES = parse2.y++ bar.c++
34 foo3_SOURCES = parse3.yxx foo.cc
35 foo4_SOURCES = parse4.ypp bar2.cxx
37 foo4_YFLAGS = $(foo3_YFLAGS)
41 @echo ' ' $(DIST_COMMON) ' '
44 cat > parse1.yy << 'END'
46 // Valid C++, but deliberately invalid C.
49 int yylex (void) { return getchar (); }
50 void yyerror (const char *s) { return; }
55 cp parse1.yy parse2.y++
56 cp parse1.yy parse3.yxx
57 cp parse1.yy parse4.ypp
60 // Valid C++, but deliberately invalid C.
62 int main (int argc, char **argv)
80 # The Yacc-derived C++ sources must be created, and not removed once
81 # compiled (i.e., not treated like "intermediate files" in the GNU
85 test -f foo3-parse3.cxx
86 test -f foo4-parse4.cpp
87 # Check that per-object flags are honored.
88 test -f foo3-parse3.output
89 test -f foo4-parse4.output
93 echo b | ./foo$i && Exit 1
94 : For shells with busted 'set -e'.
97 # The Yacc-derived C++ sources must be shipped.
99 $MAKE -s echo-distcom | grep '[ /]parse1\.cc '
100 $MAKE -s echo-distcom | grep '[ /]parse2\.c++ '
101 $MAKE -s echo-distcom | grep '[ /]foo3-parse3\.cxx '
102 $MAKE -s echo-distcom | grep '[ /]foo4-parse4\.cpp '
105 test -f $distdir/parse1.cc
106 test -f $distdir/parse2.c++
107 test -f $distdir/foo3-parse3.cxx
108 test -f $distdir/foo4-parse4.cpp
110 # Sanity check on distribution.
111 # Note that, for this to succeed, foo3-parse3.output and foo4-parse4.output
112 # must either not be distributed, or properly cleaned by automake-generated
113 # rules. We don't want to set the exact semantics yet, but want to ensure
114 # they are are consistent.
117 # Make sure that the Yacc-derived C++ sources are erased by
118 # maintainer-clean, and not by distclean.
121 test -f foo3-parse3.cxx
122 test -f foo4-parse4.cpp
127 test -f foo3-parse3.cxx
128 test -f foo4-parse4.cpp
129 ./configure # Re-create 'Makefile'.
130 $MAKE maintainer-clean
134 test ! -f foo3-parse3.cxx
135 test ! -f foo4-parse4.cpp