From: Paul Eggert Date: Mon, 22 Oct 2007 21:29:02 +0000 (-0700) Subject: * lib/autoconf/c.m4 (AC_C_RESTRICT): Work around Sun C++ compatibility X-Git-Tag: v2.62~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8186482d971cb438fa2b136dfc51250dfed687db;p=thirdparty%2Fautoconf.git * lib/autoconf/c.m4 (AC_C_RESTRICT): Work around Sun C++ compatibility problem reported by Bruno Haible in . --- diff --git a/ChangeLog b/ChangeLog index 6827771e..0044b63b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-22 Paul Eggert + and Eric Blake + + * lib/autoconf/c.m4 (AC_C_RESTRICT): Work around Sun C++ compatibility + problem reported by Bruno Haible in + . + 2007-10-22 Eric Blake * doc/autoconf.texi (Particular Types): Mention bug in HP-UX 11.00 diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 7e2d76e9..b67de57d 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1658,28 +1658,38 @@ AN_IDENTIFIER([restrict], [AC_C_RESTRICT]) AC_DEFUN([AC_C_RESTRICT], [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, [ac_cv_c_restrict=no - # Try the official restrict keyword, then gcc's __restrict, and - # the less common variants. + # 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 foo (int_ptr $ac_kw ip) { + return ip[0]; }]], [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t)]])], + int * $ac_kw t = s; + t[0] = 0; + return foo(t)]])], [ac_cv_c_restrict=$ac_kw]) test "$ac_cv_c_restrict" != no && break done ]) + AH_VERBATIM([restrict], +[/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict, even + though the corresponding Sun C compiler does, which causes + "#define restrict _Restrict" in the previous line. Perhaps some future + version of Sun C++ will work with _Restrict; if so, it'll probably + define __RESTRICT, just as Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +#endif]) case $ac_cv_c_restrict in restrict) ;; - no) AC_DEFINE(restrict,, - [Define to equivalent of C99 restrict keyword, or to nothing if this - is not supported. Do not define if restrict is supported directly.]) ;; - *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;; + no) AC_DEFINE([restrict], []) ;; + *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; esac ])# AC_C_RESTRICT