]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
autoconf: port 'restrict' to GCC 4.2.1
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Sep 2014 18:43:32 +0000 (11:43 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Sep 2014 18:44:00 +0000 (11:44 -0700)
* lib/autoconf/c.m4 (AC_C_RESTRICT): Detect GCC bug 14050.
Problem reported by Marco Munari for OpenBSD 5.5.

lib/autoconf/c.m4

index a944529579db007a101933c3a8ebae749f2cb049..a565339363303321837122a9a650ef3890798bf5 100644 (file)
@@ -1853,19 +1853,22 @@ fi
 # Otherwise, define "restrict" to be empty.
 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
 AC_DEFUN([AC_C_RESTRICT],
-[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
+[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
   [ac_cv_c_restrict=no
    # The order here caters to the fact that C++ does not require restrict.
    for ac_kw in __restrict __restrict__ _Restrict restrict; do
-     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-      [[typedef int * int_ptr;
-       int foo (int_ptr $ac_kw ip) {
-       return ip[0];
-       }]],
-      [[int s[1];
-       int * $ac_kw t = s;
-       t[0] = 0;
-       return foo(t)]])],
+     AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[typedef int *int_ptr;
+          int foo (int_ptr $ac_kw ip) { return ip[0]; }
+          int bar (int [$ac_kw]); /* Catch GCC bug 14050.  */
+          int bar (int [$ac_kw ip]) { return ip[0]; }
+        ]],
+        [[int s[1];
+          int *$ac_kw t = s;
+          t[0] = 0;
+          return foo (t) + bar (t);
+        ]])],
       [ac_cv_c_restrict=$ac_kw])
      test "$ac_cv_c_restrict" != no && break
    done