glr2.cc: provide glr_state with a genuine copy-constructor
[bison.git] / m4 / cxx.m4
blobc7dd0f905136e75eee5f01e633778835b035efa4
1 # -*- Autoconf -*-
2 # Sanity-test a C++ compiler.
4 # Copyright (C) 2004, 2006, 2009-2015, 2018-2020 Free Software
5 # Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 # Written by Paul Eggert.
22 AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
24  AC_CACHE_CHECK([whether $CXX builds executables that work],
25    bison_cv_cxx_works,
26    [AC_LANG_PUSH([C++])
27     bison_cv_cxx_works=no
28     AC_COMPILE_IFELSE(
29       [AC_LANG_PROGRAM(
30          [#include <cstdlib>
31           #include <iostream>
32           #include <map>
33           #include <string>
34           using namespace std;],
35          [std::cerr << "";
36           cout << "";
37           typedef std::pair<unsigned, int> uipair;
38           std::map<unsigned, int> m;
39           std::map<unsigned, int>::iterator i;
40           m.insert (uipair (4, -4));
41           for (i = m.begin (); i != m.end (); ++i)
42             if (i->first != 4)
43               return 1;])],
44       [AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
45          [AS_IF([test "$cross_compiling" = yes],
46             [bison_cv_cxx_works=cross],
47             [AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
48                [bison_cv_cxx_works=yes])])])
49        rm -f conftest$ac_exeext])
50     AC_LANG_POP([C++])])
52  case $bison_cv_cxx_works in
53    yes)        BISON_CXX_WORKS=':';;
54    no | cross) BISON_CXX_WORKS='false';;
55  esac
57  AC_SUBST([BISON_CXX_WORKS])
58  AM_CONDITIONAL([ENABLE_CXX], [test $bison_cv_cxx_works = yes])
61 # BISON_CXX_COMPILER_POSIXLY_CORRECT
62 # ----------------------------------
63 # Whether the C++ compiler supports -g in POSIXLY_CORRECT mode.
64 AC_DEFUN([BISON_CXX_COMPILER_POSIXLY_CORRECT],
65 [AC_LANG_PUSH([C++])
66 BISON_LANG_COMPILER_POSIXLY_CORRECT
67 AC_LANG_POP([C++])