[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/9] build: reject C++ compilers that don't support std::vector::
From: |
Akim Demaille |
Subject: |
[PATCH 5/9] build: reject C++ compilers that don't support std::vector::data |
Date: |
Thu, 12 Aug 2021 10:18:28 +0200 |
GCC 4.2 on macOS claims to support C++98, but does not feature it.
input.cc: In member function 'void state_stack::yycompressStack()':
input.cc:1774: error: 'class std::vector<glr_stack_item,
std::allocator<glr_stack_item> >' has no member named 'data'
Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.
* m4/bison-cxx-std.m4 (_BISON_CXXSTD_98_snippet): Check for it.
* m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Ditto.
---
m4/bison-cxx-std.m4 | 15 ++++++++++++++-
m4/cxx.m4 | 13 +++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/m4/bison-cxx-std.m4 b/m4/bison-cxx-std.m4
index 65d59cc7..4a71d20f 100644
--- a/m4/bison-cxx-std.m4
+++ b/m4/bison-cxx-std.m4
@@ -10,7 +10,20 @@ m4_define([_BISON_CXXSTD_98_snippet],
[[#include <cassert>
#include <vector>
-typedef std::vector<int> ints;
+void cxx98_vector ()
+{
+ typedef std::vector<int> ints;
+
+ // Check support for std::vector<T,Allocator>::data.
+ // GCC 4.2 on macOS claims to support C++98, but does not feature it.
+ //
+ // input.cc: In member function 'void state_stack::yycompressStack()':
+ // input.cc:1774: error: 'class std::vector<glr_stack_item,
std::allocator<glr_stack_item> >' has no member named 'data'
+ //
+ //
<https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.
+ ints my_ints;
+ assert (my_ints.data () == &my_ints[0]);
+}
]])
m4_define([_BISON_CXXSTD_03_snippet],
diff --git a/m4/cxx.m4 b/m4/cxx.m4
index 36e66c43..0a99fa27 100644
--- a/m4/cxx.m4
+++ b/m4/cxx.m4
@@ -27,20 +27,25 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
bison_cv_cxx_works=no
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [#include <cstdlib>
+ [[
+ #include <cassert>
+ #include <cstdlib>
#include <iostream>
#include <map>
#include <string>
- using namespace std;],
- [std::cerr << "";
+ #include <vector>
+ using namespace std;]],
+ [[std::cerr << "";
cout << "";
+ std::vector<int> ints;
+ assert(ints.data () == &ints[0]);
typedef std::pair<unsigned, int> uipair;
std::map<unsigned, int> m;
std::map<unsigned, int>::iterator i;
m.insert (uipair (4, -4));
for (i = m.begin (); i != m.end (); ++i)
if (i->first != 4)
- return 1;])],
+ return 1;]])],
[AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS
$LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
[AS_IF([test "$cross_compiling" = yes],
[bison_cv_cxx_works=cross],
--
2.32.0
- [PATCH 0/9] Various fixes for the tests, Akim Demaille, 2021/08/12
- [PATCH 1/9] c: fix _Noreturn support detection, Akim Demaille, 2021/08/12
- [PATCH 2/9] tests: be robust to old versions of xlstproc, Akim Demaille, 2021/08/12
- [PATCH 3/9] tests: remove obsolete checks, Akim Demaille, 2021/08/12
- [PATCH 4/9] build: check for C++ 20 and 2b, Akim Demaille, 2021/08/12
- [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data,
Akim Demaille <=
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Hans Åberg, 2021/08/12
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Akim Demaille, 2021/08/13
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Hans Åberg, 2021/08/13
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Akim Demaille, 2021/08/17
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Hans Åberg, 2021/08/17
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Hans Åberg, 2021/08/17
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Akim Demaille, 2021/08/19
- Re: [PATCH 5/9] build: reject C++ compilers that don't support std::vector::data, Hans Åberg, 2021/08/19
[PATCH 6/9] build: modernize to newer Autoconf releases, Akim Demaille, 2021/08/12
[PATCH 7/9] news: be clear that glr2.cc is C++11, Akim Demaille, 2021/08/12