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 // "std::" qualification required by Sun C
++ 5.9.
50 int yylex
(void
) { return std
::getchar
(); }
51 void yyerror
(const char
*s
) { return; }
56 cp parse1.yy parse2.y
++
57 cp parse1.yy parse3.yxx
58 cp parse1.yy parse4.ypp
61 // Valid C
++, but deliberately invalid C.
63 int main
(int argc
, char
**argv
)
81 # The Yacc-derived C++ sources must be created, and not removed once
82 # compiled (i.e., not treated like "intermediate files" in the GNU
86 test -f foo3-parse3.cxx
87 test -f foo4-parse4.cpp
88 # Check that per-object flags are honored.
89 test -f foo3-parse3.output
90 test -f foo4-parse4.output
92 if ! cross_compiling
; then
95 echo b | .
/foo
$i && exit 1
96 : For shells with busted
'set -e'.
100 # The Yacc-derived C++ sources must be shipped.
102 $MAKE -s echo-distcom |
grep '[ /]parse1\.cc '
103 $MAKE -s echo-distcom |
grep '[ /]parse2\.c++ '
104 $MAKE -s echo-distcom |
grep '[ /]foo3-parse3\.cxx '
105 $MAKE -s echo-distcom |
grep '[ /]foo4-parse4\.cpp '
108 test -f $distdir/parse1.cc
109 test -f $distdir/parse2.c
++
110 test -f $distdir/foo3-parse3.cxx
111 test -f $distdir/foo4-parse4.cpp
113 # Sanity check on distribution.
114 # Note that, for this to succeed, foo3-parse3.output and foo4-parse4.output
115 # must either not be distributed, or properly cleaned by automake-generated
116 # rules. We don't want to set the exact semantics yet, but want to ensure
117 # they are are consistent.
120 # Make sure that the Yacc-derived C++ sources are erased by
121 # maintainer-clean, and not by distclean.
124 test -f foo3-parse3.cxx
125 test -f foo4-parse4.cpp
130 test -f foo3-parse3.cxx
131 test -f foo4-parse4.cpp
132 .
/configure
# Re-create 'Makefile'.
133 $MAKE maintainer-clean
137 test ! -e foo3-parse3.cxx
138 test ! -e foo4-parse4.cpp