* lisp/emacs-lisp/package.el (package--with-work-buffer-async):
[emacs.git] / m4 / vararrays.m4
blob6e09c7b03989fc3f5f19a6ebc4dfba2da58ed520
1 # Check for variable-length arrays.
3 # serial 5
5 # From Paul Eggert
7 # Copyright (C) 2001, 2009-2015 Free Software Foundation, Inc.
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
12 # This is a copy of AC_C_VARARRAYS from a recent development version
13 # of Autoconf.  It replaces Autoconf's version, or for pre-2.61 autoconf
14 # it defines the macro that Autoconf lacks.
15 AC_DEFUN([AC_C_VARARRAYS],
17   AC_CACHE_CHECK([for variable-length arrays],
18     ac_cv_c_vararrays,
19     [AC_EGREP_CPP([defined],
20        [#ifdef __STDC_NO_VLA__
21         defined
22         #endif
23        ],
24        [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
25        [AC_COMPILE_IFELSE(
26           [AC_LANG_PROGRAM(
27              [[/* Test for VLA support.  This test is partly inspired
28                   from examples in the C standard.  Use at least two VLA
29                   functions to detect the GCC 3.4.3 bug described in:
30                   http://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
31                   */
32                #ifdef __STDC_NO_VLA__
33                 syntax error;
34                #else
35                  extern int n;
36                  int B[100];
37                  int fvla (int m, int C[m][m]);
39                  int
40                  simple (int count, int all[static count])
41                  {
42                    return all[count - 1];
43                  }
45                  int
46                  fvla (int m, int C[m][m])
47                  {
48                    typedef int VLA[m][m];
49                    VLA x;
50                    int D[m];
51                    static int (*q)[m] = &B;
52                    int (*s)[n] = q;
53                    return C && &x[0][0] == &D[0] && &D[0] == s[0];
54                  }
55                #endif
56                ]])],
57           [ac_cv_c_vararrays=yes],
58           [ac_cv_c_vararrays=no])])])
59   if test "$ac_cv_c_vararrays" = yes; then
60     dnl This is for compatibility with Autoconf 2.61-2.69.
61     AC_DEFINE([HAVE_C_VARARRAYS], 1,
62       [Define to 1 if C supports variable-length arrays.])
63   elif test "$ac_cv_c_vararrays" = no; then
64     AC_DEFINE([__STDC_NO_VLA__], 1,
65       [Define to 1 if C does not support variable-length arrays, and
66        if the compiler does not already define this.])
67   fi