Blame m4/vararrays.m4

Packit Service fdd496
# Check for variable-length arrays.
Packit Service fdd496
Packit Service fdd496
# serial 5
Packit Service fdd496
Packit Service fdd496
# From Paul Eggert
Packit Service fdd496
Packit Service fdd496
# Copyright (C) 2001, 2009-2017 Free Software Foundation, Inc.
Packit Service fdd496
# This file is free software; the Free Software Foundation
Packit Service fdd496
# gives unlimited permission to copy and/or distribute it,
Packit Service fdd496
# with or without modifications, as long as this notice is preserved.
Packit Service fdd496
Packit Service fdd496
# This is a copy of AC_C_VARARRAYS from a recent development version
Packit Service fdd496
# of Autoconf.  It replaces Autoconf's version, or for pre-2.61 autoconf
Packit Service fdd496
# it defines the macro that Autoconf lacks.
Packit Service fdd496
AC_DEFUN([AC_C_VARARRAYS],
Packit Service fdd496
[
Packit Service fdd496
  AC_CACHE_CHECK([for variable-length arrays],
Packit Service fdd496
    ac_cv_c_vararrays,
Packit Service fdd496
    [AC_EGREP_CPP([defined],
Packit Service fdd496
       [#ifdef __STDC_NO_VLA__
Packit Service fdd496
	defined
Packit Service fdd496
	#endif
Packit Service fdd496
       ],
Packit Service fdd496
       [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
Packit Service fdd496
       [AC_COMPILE_IFELSE(
Packit Service fdd496
	  [AC_LANG_PROGRAM(
Packit Service fdd496
	     [[/* Test for VLA support.  This test is partly inspired
Packit Service fdd496
		  from examples in the C standard.  Use at least two VLA
Packit Service fdd496
		  functions to detect the GCC 3.4.3 bug described in:
Packit Service fdd496
		  http://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
Packit Service fdd496
		  */
Packit Service fdd496
	       #ifdef __STDC_NO_VLA__
Packit Service fdd496
		syntax error;
Packit Service fdd496
	       #else
Packit Service fdd496
		 extern int n;
Packit Service fdd496
		 int B[100];
Packit Service fdd496
		 int fvla (int m, int C[m][m]);
Packit Service fdd496
Packit Service fdd496
		 int
Packit Service fdd496
		 simple (int count, int all[static count])
Packit Service fdd496
		 {
Packit Service fdd496
		   return all[count - 1];
Packit Service fdd496
		 }
Packit Service fdd496
Packit Service fdd496
		 int
Packit Service fdd496
		 fvla (int m, int C[m][m])
Packit Service fdd496
		 {
Packit Service fdd496
		   typedef int VLA[m][m];
Packit Service fdd496
		   VLA x;
Packit Service fdd496
		   int D[m];
Packit Service fdd496
		   static int (*q)[m] = &B;
Packit Service fdd496
		   int (*s)[n] = q;
Packit Service fdd496
		   return C && &x[0][0] == &D[0] && &D[0] == s[0];
Packit Service fdd496
		 }
Packit Service fdd496
	       #endif
Packit Service fdd496
	       ]])],
Packit Service fdd496
	  [ac_cv_c_vararrays=yes],
Packit Service fdd496
	  [ac_cv_c_vararrays=no])])])
Packit Service fdd496
  if test "$ac_cv_c_vararrays" = yes; then
Packit Service fdd496
    dnl This is for compatibility with Autoconf 2.61-2.69.
Packit Service fdd496
    AC_DEFINE([HAVE_C_VARARRAYS], 1,
Packit Service fdd496
      [Define to 1 if C supports variable-length arrays.])
Packit Service fdd496
  elif test "$ac_cv_c_vararrays" = no; then
Packit Service fdd496
    AC_DEFINE([__STDC_NO_VLA__], 1,
Packit Service fdd496
      [Define to 1 if C does not support variable-length arrays, and
Packit Service fdd496
       if the compiler does not already define this.])
Packit Service fdd496
  fi
Packit Service fdd496
])