xref: /netbsd-src/external/gpl3/gdb/dist/gnulib/import/m4/std-gnu11.m4 (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
18dffb485Schristos# Prefer GNU C11 and C++11 to earlier versions.  -*- coding: utf-8 -*-
28dffb485Schristos
38dffb485Schristos# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
48dffb485Schristos# commit 017d5ddd82854911f0119691d91ea8a1438824d6
58dffb485Schristos# dated Sun Apr 3 13:57:17 2016 -0700
68dffb485Schristos# This implementation will be obsolete once we can assume Autoconf 2.70
78dffb485Schristos# or later is installed everywhere a Gnulib program might be developed.
88dffb485Schristos
9*4b169a6bSchristosm4_version_prereq([2.70], [], [
108dffb485Schristos
11*4b169a6bSchristos
12*4b169a6bSchristos# Copyright (C) 2001-2022 Free Software Foundation, Inc.
138dffb485Schristos
148dffb485Schristos# This program is free software; you can redistribute it and/or modify
158dffb485Schristos# it under the terms of the GNU General Public License as published by
168dffb485Schristos# the Free Software Foundation, either version 3 of the License, or
178dffb485Schristos# (at your option) any later version.
188dffb485Schristos#
198dffb485Schristos# This program is distributed in the hope that it will be useful,
208dffb485Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
218dffb485Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
228dffb485Schristos# GNU General Public License for more details.
238dffb485Schristos#
248dffb485Schristos# You should have received a copy of the GNU General Public License
258dffb485Schristos# along with this program.  If not, see <https://www.gnu.org/licenses/>.
268dffb485Schristos
278dffb485Schristos# Written by David MacKenzie, with help from
288dffb485Schristos# Akim Demaille, Paul Eggert,
298dffb485Schristos# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
308dffb485Schristos# Roland McGrath, Noah Friedman, david d zuhn, and many others.
318dffb485Schristos
328dffb485Schristos
338dffb485Schristos# AC_PROG_CC([COMPILER ...])
348dffb485Schristos# --------------------------
358dffb485Schristos# COMPILER ... is a space separated list of C compilers to search for.
368dffb485Schristos# This just gives the user an opportunity to specify an alternative
378dffb485Schristos# search list for the C compiler.
388dffb485SchristosAC_DEFUN_ONCE([AC_PROG_CC],
398dffb485Schristos[AC_LANG_PUSH(C)dnl
408dffb485SchristosAC_ARG_VAR([CC],     [C compiler command])dnl
418dffb485SchristosAC_ARG_VAR([CFLAGS], [C compiler flags])dnl
428dffb485Schristos_AC_ARG_VAR_LDFLAGS()dnl
438dffb485Schristos_AC_ARG_VAR_LIBS()dnl
448dffb485Schristos_AC_ARG_VAR_CPPFLAGS()dnl
458dffb485Schristosm4_ifval([$1],
468dffb485Schristos      [AC_CHECK_TOOLS(CC, [$1])],
478dffb485Schristos[AC_CHECK_TOOL(CC, gcc)
488dffb485Schristosif test -z "$CC"; then
498dffb485Schristos  dnl Here we want:
508dffb485Schristos  dnl	AC_CHECK_TOOL(CC, cc)
518dffb485Schristos  dnl but without the check for a tool without the prefix.
528dffb485Schristos  dnl Until the check is removed from there, copy the code:
538dffb485Schristos  if test -n "$ac_tool_prefix"; then
548dffb485Schristos    AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
558dffb485Schristos  fi
568dffb485Schristosfi
578dffb485Schristosif test -z "$CC"; then
588dffb485Schristos  AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
598dffb485Schristosfi
608dffb485Schristosif test -z "$CC"; then
618dffb485Schristos  AC_CHECK_TOOLS(CC, cl.exe)
628dffb485Schristosfi
638dffb485Schristosif test -z "$CC"; then
648dffb485Schristos  AC_CHECK_TOOL(CC, clang)
658dffb485Schristosfi
668dffb485Schristos])
678dffb485Schristos
688dffb485Schristostest -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
698dffb485Schristos
708dffb485Schristos# Provide some information about the compiler.
718dffb485Schristos_AS_ECHO_LOG([checking for _AC_LANG compiler version])
728dffb485Schristosset X $ac_compile
738dffb485Schristosac_compiler=$[2]
748dffb485Schristosfor ac_option in --version -v -V -qversion -version; do
75*4b169a6bSchristos  _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
768dffb485Schristosdone
778dffb485Schristos
788dffb485Schristosm4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
798dffb485Schristosm4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
808dffb485Schristos_AC_LANG_COMPILER_GNU
818dffb485Schristosif test $ac_compiler_gnu = yes; then
828dffb485Schristos  GCC=yes
838dffb485Schristoselse
848dffb485Schristos  GCC=
858dffb485Schristosfi
868dffb485Schristos_AC_PROG_CC_G
878dffb485Schristosdnl
888dffb485Schristosdnl Set ac_prog_cc_stdc to the supported C version.
898dffb485Schristosdnl Also set the documented variable ac_cv_prog_cc_stdc;
908dffb485Schristosdnl its name was chosen when it was cached, but it is no longer cached.
918dffb485Schristos_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
928dffb485Schristos		 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
938dffb485Schristos  [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
948dffb485Schristos		    ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
958dffb485Schristos     [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
968dffb485Schristos		       ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
978dffb485Schristos		      [ac_prog_cc_stdc=no
988dffb485Schristos		       ac_cv_prog_cc_stdc=no])])])
998dffb485Schristosdnl
1008dffb485SchristosAC_LANG_POP(C)dnl
1018dffb485Schristos])# AC_PROG_CC
1028dffb485Schristos
1038dffb485Schristos
1048dffb485Schristos
1058dffb485Schristos# AC_PROG_CXX([LIST-OF-COMPILERS])
1068dffb485Schristos# --------------------------------
1078dffb485Schristos# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
1088dffb485Schristos# for (if not specified, a default list is used).  This just gives the
1098dffb485Schristos# user an opportunity to specify an alternative search list for the C++
1108dffb485Schristos# compiler.
1118dffb485Schristos# aCC	HP-UX C++ compiler much better than `CC', so test before.
1128dffb485Schristos# FCC   Fujitsu C++ compiler
1138dffb485Schristos# KCC	KAI C++ compiler
1148dffb485Schristos# RCC	Rational C++
1158dffb485Schristos# xlC_r	AIX C Set++ (with support for reentrant code)
1168dffb485Schristos# xlC	AIX C Set++
1178dffb485SchristosAC_DEFUN([AC_PROG_CXX],
1188dffb485Schristos[AC_LANG_PUSH(C++)dnl
1198dffb485SchristosAC_ARG_VAR([CXX],      [C++ compiler command])dnl
1208dffb485SchristosAC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
1218dffb485Schristos_AC_ARG_VAR_LDFLAGS()dnl
1228dffb485Schristos_AC_ARG_VAR_LIBS()dnl
1238dffb485Schristos_AC_ARG_VAR_CPPFLAGS()dnl
1248dffb485Schristos_AC_ARG_VAR_PRECIOUS([CCC])dnl
1258dffb485Schristosif test -z "$CXX"; then
1268dffb485Schristos  if test -n "$CCC"; then
1278dffb485Schristos    CXX=$CCC
1288dffb485Schristos  else
1298dffb485Schristos    AC_CHECK_TOOLS(CXX,
1308dffb485Schristos		   [m4_default([$1],
1318dffb485Schristos			       [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
1328dffb485Schristos		   g++)
1338dffb485Schristos  fi
1348dffb485Schristosfi
1358dffb485Schristos# Provide some information about the compiler.
1368dffb485Schristos_AS_ECHO_LOG([checking for _AC_LANG compiler version])
1378dffb485Schristosset X $ac_compile
1388dffb485Schristosac_compiler=$[2]
1398dffb485Schristosfor ac_option in --version -v -V -qversion; do
140*4b169a6bSchristos  _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
1418dffb485Schristosdone
1428dffb485Schristos
1438dffb485Schristosm4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
1448dffb485Schristosm4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
1458dffb485Schristos_AC_LANG_COMPILER_GNU
1468dffb485Schristosif test $ac_compiler_gnu = yes; then
1478dffb485Schristos  GXX=yes
1488dffb485Schristoselse
1498dffb485Schristos  GXX=
1508dffb485Schristosfi
1518dffb485Schristos_AC_PROG_CXX_G
1528dffb485Schristos_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
1538dffb485Schristos		    ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
1548dffb485Schristos		    ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
1558dffb485Schristos   [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
1568dffb485Schristos		        ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
1578dffb485Schristos		       [ac_prog_cxx_stdcxx=no
1588dffb485Schristos		        ac_cv_prog_cxx_stdcxx=no])])
1598dffb485SchristosAC_LANG_POP(C++)dnl
1608dffb485Schristos])# AC_PROG_CXX
1618dffb485Schristos
1628dffb485Schristos
1638dffb485Schristos# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
1648dffb485Schristos#		ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
1658dffb485Schristos# --------------------------------------------------------------
1668dffb485Schristos# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
1678dffb485Schristos# by trying to compile a program of TEST-PROLOGUE and TEST-BODY.  If this fails,
1688dffb485Schristos# try again with each compiler option in the space-separated OPTION-LIST; if one
1698dffb485Schristos# helps, append it to CC.  If eventually successful, run ACTION-IF-AVAILABLE,
1708dffb485Schristos# else ACTION-IF-UNAVAILABLE.
1718dffb485SchristosAC_DEFUN([_AC_C_STD_TRY],
1728dffb485Schristos[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
1738dffb485SchristosAC_CACHE_VAL(ac_cv_prog_cc_$1,
1748dffb485Schristos[ac_cv_prog_cc_$1=no
1758dffb485Schristosac_save_CC=$CC
1768dffb485SchristosAC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
1778dffb485Schristosfor ac_arg in '' $4
1788dffb485Schristosdo
1798dffb485Schristos  CC="$ac_save_CC $ac_arg"
1808dffb485Schristos  _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
1818dffb485Schristos  test "x$ac_cv_prog_cc_$1" != "xno" && break
1828dffb485Schristosdone
1838dffb485Schristosrm -f conftest.$ac_ext
1848dffb485SchristosCC=$ac_save_CC
1858dffb485Schristos])# AC_CACHE_VAL
1868dffb485Schristosac_prog_cc_stdc_options=
1878dffb485Schristoscase "x$ac_cv_prog_cc_$1" in
1888dffb485Schristos  x)
1898dffb485Schristos    AC_MSG_RESULT([none needed]) ;;
1908dffb485Schristos  xno)
1918dffb485Schristos    AC_MSG_RESULT([unsupported]) ;;
1928dffb485Schristos  *)
1938dffb485Schristos    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
1948dffb485Schristos    CC=$CC$ac_prog_cc_stdc_options
1958dffb485Schristos    AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
1968dffb485Schristosesac
1978dffb485SchristosAS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
1988dffb485Schristos])# _AC_C_STD_TRY
1998dffb485Schristos
2008dffb485Schristos# _AC_C_C99_TEST_HEADER
2018dffb485Schristos# ---------------------
2028dffb485Schristos# A C header suitable for testing for C99.
2038dffb485SchristosAC_DEFUN([_AC_C_C99_TEST_HEADER],
2048dffb485Schristos[[#include <stdarg.h>
2058dffb485Schristos#include <stdbool.h>
2068dffb485Schristos#include <stddef.h>
2078dffb485Schristos#include <stdlib.h>
2088dffb485Schristos#include <wchar.h>
2098dffb485Schristos#include <stdio.h>
2108dffb485Schristos
2118dffb485Schristos// Check varargs macros.  These examples are taken from C99 6.10.3.5.
2128dffb485Schristos#define debug(...) fprintf (stderr, __VA_ARGS__)
2138dffb485Schristos#define showlist(...) puts (#__VA_ARGS__)
2148dffb485Schristos#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
2158dffb485Schristosstatic void
2168dffb485Schristostest_varargs_macros (void)
2178dffb485Schristos{
2188dffb485Schristos  int x = 1234;
2198dffb485Schristos  int y = 5678;
2208dffb485Schristos  debug ("Flag");
2218dffb485Schristos  debug ("X = %d\n", x);
2228dffb485Schristos  showlist (The first, second, and third items.);
2238dffb485Schristos  report (x>y, "x is %d but y is %d", x, y);
2248dffb485Schristos}
2258dffb485Schristos
2268dffb485Schristos// Check long long types.
2278dffb485Schristos#define BIG64 18446744073709551615ull
2288dffb485Schristos#define BIG32 4294967295ul
2298dffb485Schristos#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
2308dffb485Schristos#if !BIG_OK
2318dffb485Schristos  your preprocessor is broken;
2328dffb485Schristos#endif
2338dffb485Schristos#if BIG_OK
2348dffb485Schristos#else
2358dffb485Schristos  your preprocessor is broken;
2368dffb485Schristos#endif
2378dffb485Schristosstatic long long int bignum = -9223372036854775807LL;
2388dffb485Schristosstatic unsigned long long int ubignum = BIG64;
2398dffb485Schristos
2408dffb485Schristosstruct incomplete_array
2418dffb485Schristos{
2428dffb485Schristos  int datasize;
2438dffb485Schristos  double data[];
2448dffb485Schristos};
2458dffb485Schristos
2468dffb485Schristosstruct named_init {
2478dffb485Schristos  int number;
2488dffb485Schristos  const wchar_t *name;
2498dffb485Schristos  double average;
2508dffb485Schristos};
2518dffb485Schristos
2528dffb485Schristostypedef const char *ccp;
2538dffb485Schristos
2548dffb485Schristosstatic inline int
2558dffb485Schristostest_restrict (ccp restrict text)
2568dffb485Schristos{
2578dffb485Schristos  // See if C++-style comments work.
2588dffb485Schristos  // Iterate through items via the restricted pointer.
2598dffb485Schristos  // Also check for declarations in for loops.
2608dffb485Schristos  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
2618dffb485Schristos    continue;
2628dffb485Schristos  return 0;
2638dffb485Schristos}
2648dffb485Schristos
2658dffb485Schristos// Check varargs and va_copy.
2668dffb485Schristosstatic bool
2678dffb485Schristostest_varargs (const char *format, ...)
2688dffb485Schristos{
2698dffb485Schristos  va_list args;
2708dffb485Schristos  va_start (args, format);
2718dffb485Schristos  va_list args_copy;
2728dffb485Schristos  va_copy (args_copy, args);
2738dffb485Schristos
2748dffb485Schristos  const char *str = "";
2758dffb485Schristos  int number = 0;
2768dffb485Schristos  float fnumber = 0;
2778dffb485Schristos
2788dffb485Schristos  while (*format)
2798dffb485Schristos    {
2808dffb485Schristos      switch (*format++)
2818dffb485Schristos	{
2828dffb485Schristos	case 's': // string
2838dffb485Schristos	  str = va_arg (args_copy, const char *);
2848dffb485Schristos	  break;
2858dffb485Schristos	case 'd': // int
2868dffb485Schristos	  number = va_arg (args_copy, int);
2878dffb485Schristos	  break;
2888dffb485Schristos	case 'f': // float
2898dffb485Schristos	  fnumber = va_arg (args_copy, double);
2908dffb485Schristos	  break;
2918dffb485Schristos	default:
2928dffb485Schristos	  break;
2938dffb485Schristos	}
2948dffb485Schristos    }
2958dffb485Schristos  va_end (args_copy);
2968dffb485Schristos  va_end (args);
2978dffb485Schristos
2988dffb485Schristos  return *str && number && fnumber;
2998dffb485Schristos}]])# _AC_C_C99_TEST_HEADER
3008dffb485Schristos
3018dffb485Schristos# _AC_C_C99_TEST_BODY
3028dffb485Schristos# -------------------
3038dffb485Schristos# A C body suitable for testing for C99, assuming the corresponding header.
3048dffb485SchristosAC_DEFUN([_AC_C_C99_TEST_BODY],
3058dffb485Schristos[[
3068dffb485Schristos  // Check bool.
3078dffb485Schristos  _Bool success = false;
3088dffb485Schristos
3098dffb485Schristos  // Check restrict.
3108dffb485Schristos  if (test_restrict ("String literal") == 0)
3118dffb485Schristos    success = true;
3128dffb485Schristos  char *restrict newvar = "Another string";
3138dffb485Schristos
3148dffb485Schristos  // Check varargs.
3158dffb485Schristos  success &= test_varargs ("s, d' f .", "string", 65, 34.234);
3168dffb485Schristos  test_varargs_macros ();
3178dffb485Schristos
3188dffb485Schristos  // Check flexible array members.
3198dffb485Schristos  struct incomplete_array *ia =
3208dffb485Schristos    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
3218dffb485Schristos  ia->datasize = 10;
3228dffb485Schristos  for (int i = 0; i < ia->datasize; ++i)
3238dffb485Schristos    ia->data[i] = i * 1.234;
3248dffb485Schristos
3258dffb485Schristos  // Check named initializers.
3268dffb485Schristos  struct named_init ni = {
3278dffb485Schristos    .number = 34,
3288dffb485Schristos    .name = L"Test wide string",
3298dffb485Schristos    .average = 543.34343,
3308dffb485Schristos  };
3318dffb485Schristos
3328dffb485Schristos  ni.number = 58;
3338dffb485Schristos
3348dffb485Schristos  int dynamic_array[ni.number];
3358dffb485Schristos  dynamic_array[ni.number - 1] = 543;
3368dffb485Schristos
3378dffb485Schristos  // work around unused variable warnings
3388dffb485Schristos  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
3398dffb485Schristos	  || dynamic_array[ni.number - 1] != 543);
3408dffb485Schristos]])
3418dffb485Schristos
3428dffb485Schristos# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
3438dffb485Schristos# ----------------------------------------------------------------
3448dffb485Schristos# If the C compiler is not in ISO C99 mode by default, try to add an
3458dffb485Schristos# option to output variable CC to make it so.  This macro tries
3468dffb485Schristos# various options that select ISO C99 on some system or another.  It
3478dffb485Schristos# considers the compiler to be in ISO C99 mode if it handles _Bool,
3488dffb485Schristos# // comments, flexible array members, inline, long long int, mixed
3498dffb485Schristos# code and declarations, named initialization of structs, restrict,
3508dffb485Schristos# va_copy, varargs macros, variable declarations in for loops and
3518dffb485Schristos# variable length arrays.
3528dffb485SchristosAC_DEFUN([_AC_PROG_CC_C99],
3538dffb485Schristos[_AC_C_STD_TRY([c99],
3548dffb485Schristos[_AC_C_C99_TEST_HEADER],
3558dffb485Schristos[_AC_C_C99_TEST_BODY],
3568dffb485Schristosdnl Try
3578dffb485Schristosdnl GCC		-std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
3588dffb485Schristosdnl IBM XL C	-qlanglvl=extc1x (V12.1; does not pass C11 test)
3598dffb485Schristosdnl IBM XL C	-qlanglvl=extc99
3608dffb485Schristosdnl		(pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
3618dffb485Schristosdnl HP cc	-AC99
3628dffb485Schristosdnl Intel ICC	-std=c99, -c99 (deprecated)
3638dffb485Schristosdnl IRIX	-c99
3648dffb485Schristosdnl Solaris	-D_STDC_C99=
3658dffb485Schristosdnl		cc's -xc99 option uses linker magic to define the external
3668dffb485Schristosdnl		symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
3678dffb485Schristosdnl		behavior for C library functions.  This is not wanted here,
3688dffb485Schristosdnl		because it means that a single module compiled with -xc99
3698dffb485Schristosdnl		alters C runtime behavior for the entire program, not for
3708dffb485Schristosdnl		just the module.  Instead, define the (private) symbol
3718dffb485Schristosdnl		_STDC_C99, which suppresses a bogus failure in <stdbool.h>.
3728dffb485Schristosdnl		The resulting compiler passes the test case here, and that's
3738dffb485Schristosdnl		good enough.  For more, please see the thread starting at:
3748dffb485Schristosdnl            https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
3758dffb485Schristosdnl Tru64	-c99
3768dffb485Schristosdnl with extended modes being tried first.
3778dffb485Schristos[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
3788dffb485Schristos])# _AC_PROG_CC_C99
3798dffb485Schristos
3808dffb485Schristos
3818dffb485Schristos# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
3828dffb485Schristos# ----------------------------------------------------------------
3838dffb485Schristos# If the C compiler is not in ISO C11 mode by default, try to add an
3848dffb485Schristos# option to output variable CC to make it so.  This macro tries
3858dffb485Schristos# various options that select ISO C11 on some system or another.  It
3868dffb485Schristos# considers the compiler to be in ISO C11 mode if it handles _Alignas,
3878dffb485Schristos# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
3888dffb485Schristos# duplicate typedefs, and anonymous structures and unions.
3898dffb485SchristosAC_DEFUN([_AC_PROG_CC_C11],
3908dffb485Schristos[_AC_C_STD_TRY([c11],
3918dffb485Schristos[_AC_C_C99_TEST_HEADER[
3928dffb485Schristos// Check _Alignas.
3938dffb485Schristoschar _Alignas (double) aligned_as_double;
3948dffb485Schristoschar _Alignas (0) no_special_alignment;
3958dffb485Schristosextern char aligned_as_int;
3968dffb485Schristoschar _Alignas (0) _Alignas (int) aligned_as_int;
3978dffb485Schristos
3988dffb485Schristos// Check _Alignof.
3998dffb485Schristosenum
4008dffb485Schristos{
4018dffb485Schristos  int_alignment = _Alignof (int),
4028dffb485Schristos  int_array_alignment = _Alignof (int[100]),
4038dffb485Schristos  char_alignment = _Alignof (char)
4048dffb485Schristos};
4058dffb485Schristos_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
4068dffb485Schristos
4078dffb485Schristos// Check _Noreturn.
4088dffb485Schristosint _Noreturn does_not_return (void) { for (;;) continue; }
4098dffb485Schristos
4108dffb485Schristos// Check _Static_assert.
4118dffb485Schristosstruct test_static_assert
4128dffb485Schristos{
4138dffb485Schristos  int x;
4148dffb485Schristos  _Static_assert (sizeof (int) <= sizeof (long int),
4158dffb485Schristos                  "_Static_assert does not work in struct");
4168dffb485Schristos  long int y;
4178dffb485Schristos};
4188dffb485Schristos
4198dffb485Schristos// Check UTF-8 literals.
4208dffb485Schristos#define u8 syntax error!
4218dffb485Schristoschar const utf8_literal[] = u8"happens to be ASCII" "another string";
4228dffb485Schristos
4238dffb485Schristos// Check duplicate typedefs.
4248dffb485Schristostypedef long *long_ptr;
4258dffb485Schristostypedef long int *long_ptr;
4268dffb485Schristostypedef long_ptr long_ptr;
4278dffb485Schristos
4288dffb485Schristos// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
4298dffb485Schristosstruct anonymous
4308dffb485Schristos{
4318dffb485Schristos  union {
4328dffb485Schristos    struct { int i; int j; };
4338dffb485Schristos    struct { int k; long int l; } w;
4348dffb485Schristos  };
4358dffb485Schristos  int m;
4368dffb485Schristos} v1;
4378dffb485Schristos]],
4388dffb485Schristos[_AC_C_C99_TEST_BODY[
4398dffb485Schristos  v1.i = 2;
4408dffb485Schristos  v1.w.k = 5;
4418dffb485Schristos  _Static_assert ((offsetof (struct anonymous, i)
4428dffb485Schristos		   == offsetof (struct anonymous, w.k)),
4438dffb485Schristos		  "Anonymous union alignment botch");
4448dffb485Schristos]],
4458dffb485Schristosdnl Try
4468dffb485Schristosdnl GCC		-std=gnu11 (unused restrictive mode: -std=c11)
4478dffb485Schristosdnl with extended modes being tried first.
4488dffb485Schristosdnl
4498dffb485Schristosdnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
4508dffb485Schristosdnl of September 2012) does not pass the C11 test.  For now, try extc1x when
4518dffb485Schristosdnl compiling the C99 test instead, since it enables _Static_assert and
4528dffb485Schristosdnl _Noreturn, which is a win.  If -qlanglvl=extc11 or -qlanglvl=extc1x passes
4538dffb485Schristosdnl the C11 test in some future version of IBM XL C, we'll add it here,
4548dffb485Schristosdnl preferably extc11.
4558dffb485Schristos[[-std=gnu11]], [$1], [$2])[]dnl
4568dffb485Schristos])# _AC_PROG_CC_C11
4578dffb485Schristos
4588dffb485Schristos
4598dffb485Schristos# AC_PROG_CC_C89
4608dffb485Schristos# --------------
4618dffb485Schristos# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
4628dffb485Schristos# as that'd be incompatible with how Automake redefines AC_PROG_CC.  See
4638dffb485Schristos# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
4648dffb485SchristosAU_DEFUN([AC_PROG_CC_C89],
4658dffb485Schristos  [AC_REQUIRE([AC_PROG_CC])],
4668dffb485Schristos  [$0 is obsolete; use AC_PROG_CC]
4678dffb485Schristos)
4688dffb485Schristos
4698dffb485Schristos# AC_PROG_CC_C99
4708dffb485Schristos# --------------
4718dffb485SchristosAU_DEFUN([AC_PROG_CC_C99],
4728dffb485Schristos  [AC_REQUIRE([AC_PROG_CC])],
4738dffb485Schristos  [$0 is obsolete; use AC_PROG_CC]
4748dffb485Schristos)
4758dffb485Schristos
4768dffb485Schristos# AC_PROG_CC_STDC
4778dffb485Schristos# ---------------
4788dffb485SchristosAU_DEFUN([AC_PROG_CC_STDC],
4798dffb485Schristos  [AC_REQUIRE([AC_PROG_CC])],
4808dffb485Schristos  [$0 is obsolete; use AC_PROG_CC]
4818dffb485Schristos)
4828dffb485Schristos
4838dffb485Schristos
4848dffb485Schristos# AC_C_PROTOTYPES
4858dffb485Schristos# ---------------
4868dffb485Schristos# Check if the C compiler supports prototypes, included if it needs
4878dffb485Schristos# options.
4888dffb485SchristosAC_DEFUN([AC_C_PROTOTYPES],
4898dffb485Schristos[AC_REQUIRE([AC_PROG_CC])dnl
4908dffb485Schristosif test "$ac_prog_cc_stdc" != no; then
4918dffb485Schristos  AC_DEFINE(PROTOTYPES, 1,
4928dffb485Schristos	    [Define to 1 if the C compiler supports function prototypes.])
4938dffb485Schristos  AC_DEFINE(__PROTOTYPES, 1,
4948dffb485Schristos	    [Define like PROTOTYPES; this can be used by system headers.])
4958dffb485Schristosfi
4968dffb485Schristos])# AC_C_PROTOTYPES
4978dffb485Schristos
4988dffb485Schristos
4998dffb485Schristos# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
5008dffb485Schristos#		  ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
5018dffb485Schristos# ----------------------------------------------------------------
5028dffb485Schristos# Check whether the C++ compiler accepts features of STANDARD (e.g
5038dffb485Schristos# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
5048dffb485Schristos# and TEST-BODY.  If this fails, try again with each compiler option
5058dffb485Schristos# in the space-separated OPTION-LIST; if one helps, append it to CXX.
5068dffb485Schristos# If eventually successful, run ACTION-IF-AVAILABLE, else
5078dffb485Schristos# ACTION-IF-UNAVAILABLE.
5088dffb485SchristosAC_DEFUN([_AC_CXX_STD_TRY],
5098dffb485Schristos[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
5108dffb485SchristosAC_LANG_PUSH(C++)dnl
5118dffb485SchristosAC_CACHE_VAL(ac_cv_prog_cxx_$1,
5128dffb485Schristos[ac_cv_prog_cxx_$1=no
5138dffb485Schristosac_save_CXX=$CXX
5148dffb485SchristosAC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
5158dffb485Schristosfor ac_arg in '' $4
5168dffb485Schristosdo
5178dffb485Schristos  CXX="$ac_save_CXX $ac_arg"
5188dffb485Schristos  _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
5198dffb485Schristos  test "x$ac_cv_prog_cxx_$1" != "xno" && break
5208dffb485Schristosdone
5218dffb485Schristosrm -f conftest.$ac_ext
5228dffb485SchristosCXX=$ac_save_CXX
5238dffb485Schristos])# AC_CACHE_VAL
5248dffb485Schristosac_prog_cxx_stdcxx_options=
5258dffb485Schristoscase "x$ac_cv_prog_cxx_$1" in
5268dffb485Schristos  x)
5278dffb485Schristos    AC_MSG_RESULT([none needed]) ;;
5288dffb485Schristos  xno)
5298dffb485Schristos    AC_MSG_RESULT([unsupported]) ;;
5308dffb485Schristos  *)
5318dffb485Schristos    ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
5328dffb485Schristos    CXX=$CXX$ac_prog_cxx_stdcxx_options
5338dffb485Schristos    AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
5348dffb485Schristosesac
5358dffb485SchristosAC_LANG_POP(C++)dnl
5368dffb485SchristosAS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
5378dffb485Schristos])# _AC_CXX_STD_TRY
5388dffb485Schristos
5398dffb485Schristos# _AC_CXX_CXX98_TEST_HEADER
5408dffb485Schristos# -------------------------
5418dffb485Schristos# A C++ header suitable for testing for CXX98.
5428dffb485SchristosAC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
5438dffb485Schristos[[
5448dffb485Schristos#include <algorithm>
5458dffb485Schristos#include <cstdlib>
5468dffb485Schristos#include <fstream>
5478dffb485Schristos#include <iomanip>
5488dffb485Schristos#include <iostream>
5498dffb485Schristos#include <list>
5508dffb485Schristos#include <map>
5518dffb485Schristos#include <set>
5528dffb485Schristos#include <sstream>
5538dffb485Schristos#include <stdexcept>
5548dffb485Schristos#include <string>
5558dffb485Schristos#include <utility>
5568dffb485Schristos#include <vector>
5578dffb485Schristos
5588dffb485Schristosnamespace test {
5598dffb485Schristos  typedef std::vector<std::string> string_vec;
5608dffb485Schristos  typedef std::pair<int,bool> map_value;
5618dffb485Schristos  typedef std::map<std::string,map_value> map_type;
5628dffb485Schristos  typedef std::set<int> set_type;
5638dffb485Schristos
5648dffb485Schristos  template<typename T>
5658dffb485Schristos  class printer {
5668dffb485Schristos  public:
5678dffb485Schristos    printer(std::ostringstream& os): os(os) {}
5688dffb485Schristos    void operator() (T elem) { os << elem << std::endl; }
5698dffb485Schristos  private:
5708dffb485Schristos    std::ostringstream& os;
5718dffb485Schristos  };
5728dffb485Schristos}
5738dffb485Schristos]])# _AC_CXX_CXX98_TEST_HEADER
5748dffb485Schristos
5758dffb485Schristos# _AC_CXX_CXX98_TEST_BODY
5768dffb485Schristos# -----------------------
5778dffb485Schristos# A C++ body suitable for testing for CXX98, assuming the corresponding header.
5788dffb485SchristosAC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
5798dffb485Schristos[[
5808dffb485Schristos
5818dffb485Schristostry {
5828dffb485Schristos  // Basic string.
5838dffb485Schristos  std::string teststr("ASCII text");
5848dffb485Schristos  teststr += " string";
5858dffb485Schristos
5868dffb485Schristos  // Simple vector.
5878dffb485Schristos  test::string_vec testvec;
5888dffb485Schristos  testvec.push_back(teststr);
5898dffb485Schristos  testvec.push_back("foo");
5908dffb485Schristos  testvec.push_back("bar");
5918dffb485Schristos  if (testvec.size() != 3) {
5928dffb485Schristos    throw std::runtime_error("vector size is not 1");
5938dffb485Schristos  }
5948dffb485Schristos
5958dffb485Schristos  // Dump vector into stringstream and obtain string.
5968dffb485Schristos  std::ostringstream os;
5978dffb485Schristos  for (test::string_vec::const_iterator i = testvec.begin();
5988dffb485Schristos       i != testvec.end(); ++i) {
5998dffb485Schristos    if (i + 1 != testvec.end()) {
6008dffb485Schristos      os << teststr << '\n';
6018dffb485Schristos    }
6028dffb485Schristos  }
6038dffb485Schristos  // Check algorithms work.
6048dffb485Schristos  std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
6058dffb485Schristos  std::string os_out = os.str();
6068dffb485Schristos
6078dffb485Schristos  // Test pair and map.
6088dffb485Schristos  test::map_type testmap;
6098dffb485Schristos  testmap.insert(std::make_pair(std::string("key"),
6108dffb485Schristos                                std::make_pair(53,false)));
6118dffb485Schristos
6128dffb485Schristos  // Test set.
6138dffb485Schristos  int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
6148dffb485Schristos  test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
6158dffb485Schristos  std::list<int> testlist(testset.begin(), testset.end());
6168dffb485Schristos  std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
6178dffb485Schristos} catch (const std::exception& e) {
6188dffb485Schristos  std::cerr << "Caught exception: " << e.what() << std::endl;
6198dffb485Schristos
6208dffb485Schristos  // Test fstream
6218dffb485Schristos  std::ofstream of("test.txt");
6228dffb485Schristos  of << "Test ASCII text\n" << std::flush;
6238dffb485Schristos  of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
6248dffb485Schristos  of.close();
6258dffb485Schristos}
6268dffb485Schristosstd::exit(0);
6278dffb485Schristos]])
6288dffb485Schristos
6298dffb485Schristos# _AC_CXX_CXX11_TEST_HEADER
6308dffb485Schristos# -------------------------
6318dffb485Schristos# A C++ header suitable for testing for CXX11.
6328dffb485SchristosAC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
6338dffb485Schristos[[
6348dffb485Schristos#include <deque>
6358dffb485Schristos#include <functional>
6368dffb485Schristos#include <memory>
6378dffb485Schristos#include <tuple>
6388dffb485Schristos#include <array>
6398dffb485Schristos#include <regex>
6408dffb485Schristos#include <iostream>
6418dffb485Schristos
6428dffb485Schristosnamespace cxx11test
6438dffb485Schristos{
6448dffb485Schristos  typedef std::shared_ptr<std::string> sptr;
6458dffb485Schristos  typedef std::weak_ptr<std::string> wptr;
6468dffb485Schristos
6478dffb485Schristos  typedef std::tuple<std::string,int,double> tp;
6488dffb485Schristos  typedef std::array<int, 20> int_array;
6498dffb485Schristos
6508dffb485Schristos  constexpr int get_val() { return 20; }
6518dffb485Schristos
6528dffb485Schristos  struct testinit
6538dffb485Schristos  {
6548dffb485Schristos    int i;
6558dffb485Schristos    double d;
6568dffb485Schristos  };
6578dffb485Schristos
6588dffb485Schristos  class delegate  {
6598dffb485Schristos  public:
6608dffb485Schristos    delegate(int n) : n(n) {}
6618dffb485Schristos    delegate(): delegate(2354) {}
6628dffb485Schristos
6638dffb485Schristos    virtual int getval() { return this->n; };
6648dffb485Schristos  protected:
6658dffb485Schristos    int n;
6668dffb485Schristos  };
6678dffb485Schristos
6688dffb485Schristos  class overridden : public delegate {
6698dffb485Schristos  public:
6708dffb485Schristos    overridden(int n): delegate(n) {}
6718dffb485Schristos    virtual int getval() override final { return this->n * 2; }
6728dffb485Schristos  };
6738dffb485Schristos
6748dffb485Schristos  class nocopy {
6758dffb485Schristos  public:
6768dffb485Schristos    nocopy(int i): i(i) {}
6778dffb485Schristos    nocopy() = default;
6788dffb485Schristos    nocopy(const nocopy&) = delete;
6798dffb485Schristos    nocopy & operator=(const nocopy&) = delete;
6808dffb485Schristos  private:
6818dffb485Schristos    int i;
6828dffb485Schristos  };
6838dffb485Schristos}
6848dffb485Schristos]])# _AC_CXX_CXX11_TEST_HEADER
6858dffb485Schristos
6868dffb485Schristos# _AC_CXX_CXX11_TEST_BODY
6878dffb485Schristos# -----------------------
6888dffb485Schristos# A C++ body suitable for testing for CXX11, assuming the corresponding header.
6898dffb485SchristosAC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
6908dffb485Schristos[[
6918dffb485Schristos{
6928dffb485Schristos  // Test auto and decltype
6938dffb485Schristos  std::deque<int> d;
6948dffb485Schristos  d.push_front(43);
6958dffb485Schristos  d.push_front(484);
6968dffb485Schristos  d.push_front(3);
6978dffb485Schristos  d.push_front(844);
6988dffb485Schristos  int total = 0;
6998dffb485Schristos  for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
7008dffb485Schristos
7018dffb485Schristos  auto a1 = 6538;
7028dffb485Schristos  auto a2 = 48573953.4;
7038dffb485Schristos  auto a3 = "String literal";
7048dffb485Schristos
7058dffb485Schristos  decltype(a2) a4 = 34895.034;
7068dffb485Schristos}
7078dffb485Schristos{
7088dffb485Schristos  // Test constexpr
7098dffb485Schristos  short sa[cxx11test::get_val()] = { 0 };
7108dffb485Schristos}
7118dffb485Schristos{
7128dffb485Schristos  // Test initializer lists
7138dffb485Schristos  cxx11test::testinit il = { 4323, 435234.23544 };
7148dffb485Schristos}
7158dffb485Schristos{
7168dffb485Schristos  // Test range-based for and lambda
7178dffb485Schristos  cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
7188dffb485Schristos  for (int &x : array) { x += 23; }
7198dffb485Schristos  std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
7208dffb485Schristos}
7218dffb485Schristos{
7228dffb485Schristos  using cxx11test::sptr;
7238dffb485Schristos  using cxx11test::wptr;
7248dffb485Schristos
7258dffb485Schristos  sptr sp(new std::string("ASCII string"));
7268dffb485Schristos  wptr wp(sp);
7278dffb485Schristos  sptr sp2(wp);
7288dffb485Schristos}
7298dffb485Schristos{
7308dffb485Schristos  cxx11test::tp tuple("test", 54, 45.53434);
7318dffb485Schristos  double d = std::get<2>(tuple);
7328dffb485Schristos  std::string s;
7338dffb485Schristos  int i;
7348dffb485Schristos  std::tie(s,i,d) = tuple;
7358dffb485Schristos}
7368dffb485Schristos{
7378dffb485Schristos  static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
7388dffb485Schristos  std::string testmatch("Test if this string matches");
7398dffb485Schristos  bool match = std::regex_search(testmatch, filename_regex);
7408dffb485Schristos}
7418dffb485Schristos{
7428dffb485Schristos  cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
7438dffb485Schristos  cxx11test::int_array::size_type size = array.size();
7448dffb485Schristos}
7458dffb485Schristos{
7468dffb485Schristos  // Test constructor delegation
7478dffb485Schristos  cxx11test::delegate d1;
7488dffb485Schristos  cxx11test::delegate d2();
7498dffb485Schristos  cxx11test::delegate d3(45);
7508dffb485Schristos}
7518dffb485Schristos{
7528dffb485Schristos  // Test override and final
7538dffb485Schristos  cxx11test::overridden o1(55464);
7548dffb485Schristos}
7558dffb485Schristos{
7568dffb485Schristos  // Test nullptr
7578dffb485Schristos  char *c = nullptr;
7588dffb485Schristos}
7598dffb485Schristos{
7608dffb485Schristos  // Test template brackets
7618dffb485Schristos  std::vector<std::pair<int,char*>> v1;
7628dffb485Schristos}
7638dffb485Schristos{
7648dffb485Schristos  // Unicode literals
7658dffb485Schristos  char const *utf8 = u8"UTF-8 string \u2500";
7668dffb485Schristos  char16_t const *utf16 = u"UTF-8 string \u2500";
7678dffb485Schristos  char32_t const *utf32 = U"UTF-32 string \u2500";
7688dffb485Schristos}
7698dffb485Schristos]])
7708dffb485Schristos
7718dffb485Schristos# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
7728dffb485Schristos# -------------------------------------------------------------------
7738dffb485Schristos
7748dffb485Schristos# If the C++ compiler is not in ISO C++98 mode by default, try to add
7758dffb485Schristos# an option to output variable CXX to make it so.  This macro tries
7768dffb485Schristos# various options that select ISO C++98 on some system or another.  It
7778dffb485Schristos# considers the compiler to be in ISO C++98 mode if it handles basic
7788dffb485Schristos# features of the std namespace including: string, containers (list,
7798dffb485Schristos# map, set, vector), streams (fstreams, iostreams, stringstreams,
7808dffb485Schristos# iomanip), pair, exceptions and algorithms.
7818dffb485Schristos
7828dffb485Schristos
7838dffb485SchristosAC_DEFUN([_AC_PROG_CXX_CXX98],
7848dffb485Schristos[_AC_CXX_STD_TRY([cxx98],
7858dffb485Schristos[_AC_CXX_CXX98_TEST_HEADER],
7868dffb485Schristos[_AC_CXX_CXX98_TEST_BODY],
7878dffb485Schristosdnl Try
7888dffb485Schristosdnl GCC		-std=gnu++98 (unused restrictive mode: -std=c++98)
7898dffb485Schristosdnl IBM XL C	-qlanglvl=extended
7908dffb485Schristosdnl HP aC++	-AA
7918dffb485Schristosdnl Intel ICC	-std=gnu++98
7928dffb485Schristosdnl Solaris	N/A (default)
7938dffb485Schristosdnl Tru64	N/A (default, but -std gnu could be used)
7948dffb485Schristosdnl with extended modes being tried first.
7958dffb485Schristos[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
7968dffb485Schristos])# _AC_PROG_CXX_CXX98
7978dffb485Schristos
7988dffb485Schristos# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
7998dffb485Schristos# -------------------------------------------------------------------
8008dffb485Schristos# If the C++ compiler is not in ISO CXX11 mode by default, try to add
8018dffb485Schristos# an option to output variable CXX to make it so.  This macro tries
8028dffb485Schristos# various options that select ISO C++11 on some system or another.  It
8038dffb485Schristos# considers the compiler to be in ISO C++11 mode if it handles all the
8048dffb485Schristos# tests from the C++98 checks, plus the following: Language features
8058dffb485Schristos# (auto, constexpr, decltype, default/deleted constructors, delegate
8068dffb485Schristos# constructors, final, initializer lists, lambda functions, nullptr,
8078dffb485Schristos# override, range-based for loops, template brackets without spaces,
8088dffb485Schristos# unicode literals) and library features (array, memory (shared_ptr,
8098dffb485Schristos# weak_ptr), regex and tuple types).
8108dffb485SchristosAC_DEFUN([_AC_PROG_CXX_CXX11],
8118dffb485Schristos[_AC_CXX_STD_TRY([cxx11],
8128dffb485Schristos[_AC_CXX_CXX11_TEST_HEADER
8138dffb485Schristos_AC_CXX_CXX98_TEST_HEADER],
8148dffb485Schristos[_AC_CXX_CXX11_TEST_BODY
8158dffb485Schristos_AC_CXX_CXX98_TEST_BODY],
8168dffb485Schristosdnl Try
8178dffb485Schristosdnl GCC		-std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
8188dffb485Schristosdnl IBM XL C	-qlanglvl=extended0x
8198dffb485Schristosdnl		(pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
8208dffb485Schristosdnl HP aC++	-AA
8218dffb485Schristosdnl Intel ICC	-std=c++11 -std=c++0x
8228dffb485Schristosdnl Solaris	N/A (no support)
8238dffb485Schristosdnl Tru64	N/A (no support)
8248dffb485Schristosdnl with extended modes being tried first.
8258dffb485Schristos[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
8268dffb485Schristos])# _AC_PROG_CXX_CXX11
827*4b169a6bSchristos
828*4b169a6bSchristos
829*4b169a6bSchristos])# m4_version_prereq
830