Skip to content

Commit 4f6a4d3

Browse files
committed
autoconf: support running the C++11 config checks with warning errors.
1 parent f892b85 commit 4f6a4d3

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

m4/cxx11.m4

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# cxx11.m4 serial 6
2-
dnl Copyright (C) 2012 Reece H. Dunn
2+
dnl Copyright (C) 2012-2015 Reece H. Dunn
33
dnl
44
dnl This file is free software; Reece H. Dunn
55
dnl gives unlimited permission to copy and/or distribute it,
@@ -117,7 +117,8 @@ AC_DEFUN([CXX11_NULLPTR], [
117117
AC_COMPILE_IFELSE(
118118
[AC_LANG_PROGRAM(
119119
[[]],
120-
[[const char *ptr = nullptr;]])],
120+
[[const char *ptr = nullptr;]
121+
[(void)ptr;]])],
121122
[AC_MSG_RESULT([yes])],
122123
[AC_MSG_RESULT([no])
123124
AC_MSG_ERROR([C++11 nullptr not supported by $CXX.])])
@@ -133,8 +134,9 @@ AC_DEFUN([CXX11_DECLTYPE], [
133134
AC_COMPILE_IFELSE(
134135
[AC_LANG_PROGRAM(
135136
[[]],
136-
[[int a;]
137-
[decltype(a) b = a;]])],
137+
[[int a = 4;]
138+
[decltype(a) b = a;]
139+
[(void)b;]])],
138140
[AC_MSG_RESULT([yes])],
139141
[AC_MSG_RESULT([no])
140142
AC_MSG_ERROR([C++11 decltype not supported by $CXX.])])
@@ -151,7 +153,8 @@ AC_DEFUN([CXX11_AUTO], [
151153
[AC_LANG_PROGRAM(
152154
[[]],
153155
[[class A {} a;]
154-
[auto b = a;]])],
156+
[auto b = a;]
157+
[(void)b;]])],
155158
[AC_MSG_RESULT([yes])],
156159
[AC_MSG_RESULT([no])
157160
AC_MSG_ERROR([C++11 auto not supported by $CXX.])])
@@ -194,7 +197,8 @@ AC_DEFUN([CXX11_BRACE_INITIALIZATION], [
194197
[AC_LANG_PROGRAM(
195198
[[#include <complex>]],
196199
[[struct A { std::complex<float> c; };]
197-
[A a { { 0.1, 0.2 } };]])],
200+
[A a { { 0.1, 0.2 } };]
201+
[(void)a;]])],
198202
[AC_MSG_RESULT([yes])],
199203
[AC_MSG_RESULT([no])
200204
AC_MSG_ERROR([C++11 brace initialization of a class in a struct not supported by $CXX.])])
@@ -231,7 +235,8 @@ AC_DEFUN([CXX11_CONSTEXPR], [
231235
AC_MSG_CHECKING([if $CXX supports C++11 constexpr])
232236
AC_COMPILE_IFELSE(
233237
[AC_LANG_PROGRAM(
234-
[[constexpr float value = 1.25;]])],
238+
[[constexpr float value = 1.25;]
239+
[float f = value;]])],
235240
[AC_MSG_RESULT([yes])],
236241
[AC_MSG_RESULT([no])
237242
AC_MSG_ERROR([C++11 constexpr not supported by $CXX.])])
@@ -246,7 +251,10 @@ AC_DEFUN([CXX11_LAMBDA], [
246251
AC_MSG_CHECKING([if $CXX supports C++11 lambda])
247252
AC_COMPILE_IFELSE(
248253
[AC_LANG_PROGRAM(
249-
[[auto f = [](int x) -> int { return x; };]])],
254+
[[]],
255+
[[auto f = [](int x) -> int { return x; };]
256+
[int val = f(3);]
257+
[(void)val;]])],
250258
[AC_MSG_RESULT([yes])],
251259
[AC_MSG_RESULT([no])
252260
AC_MSG_ERROR([C++11 lambda not supported by $CXX.])])
@@ -257,8 +265,10 @@ AC_DEFUN([CXX11_LAMBDA_CAPTURE], [
257265
AC_MSG_CHECKING([if $CXX supports C++11 lambda captures])
258266
AC_COMPILE_IFELSE(
259267
[AC_LANG_PROGRAM(
268+
[[]],
260269
[[int val = 0;]
261-
[auto f = [&val](int x) { val = x; };]])],
270+
[auto f = [&val](int x) { val = x; };]
271+
[f(3);]])],
262272
[AC_MSG_RESULT([yes])],
263273
[AC_MSG_RESULT([no])
264274
AC_MSG_ERROR([C++11 lambda captures not supported by $CXX.])])
@@ -333,7 +343,8 @@ AC_DEFUN([CXX11_HAVE_STD_BEGIN], [
333343
[AC_LANG_PROGRAM(
334344
[[#include <iterator>]],
335345
[[int data[] = { 1, 2, 3, 4, 5 };]
336-
[int *first = std::begin(data);]])],
346+
[int *first = std::begin(data);]
347+
[(void)first;]])],
337348
[AC_MSG_RESULT([yes])
338349
AC_DEFINE([HAVE_CXX11_STD_BEGIN],[1],[Define to 1 if std::begin is supported.])],
339350
[AC_MSG_RESULT([no])])
@@ -346,7 +357,8 @@ AC_DEFUN([CXX11_REQUIRE_STD_BEGIN], [
346357
[AC_LANG_PROGRAM(
347358
[[#include <iterator>]],
348359
[[int data[] = { 1, 2, 3, 4, 5 };]
349-
[int *first = std::begin(data);]])],
360+
[int *first = std::begin(data);]
361+
[(void)first;]])],
350362
[AC_MSG_RESULT([yes])],
351363
[AC_MSG_RESULT([no])
352364
AC_MSG_ERROR([C++11 std::begin not supported by $CXX.])])
@@ -363,7 +375,8 @@ AC_DEFUN([CXX11_HAVE_STD_END], [
363375
[AC_LANG_PROGRAM(
364376
[[#include <iterator>]],
365377
[[int data[] = { 1, 2, 3, 4, 5 };]
366-
[int *last = std::end(data);]])],
378+
[int *last = std::end(data);]
379+
[(void)last;]])],
367380
[AC_MSG_RESULT([yes])
368381
AC_DEFINE([HAVE_CXX11_STD_END],[1],[Define to 1 if std::end is supported.])],
369382
[AC_MSG_RESULT([no])])
@@ -376,7 +389,8 @@ AC_DEFUN([CXX11_REQUIRE_STD_END], [
376389
[AC_LANG_PROGRAM(
377390
[[#include <iterator>]],
378391
[[int data[] = { 1, 2, 3, 4, 5 };]
379-
[int *last = std::end(data);]])],
392+
[int *last = std::end(data);]
393+
[(void)last;]])],
380394
[AC_MSG_RESULT([yes])],
381395
[AC_MSG_RESULT([no])
382396
AC_MSG_ERROR([C++11 std::end not supported by $CXX.])])

0 commit comments

Comments
 (0)