autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_C_RESTRICT


From: Albert Chin
Subject: Re: AC_C_RESTRICT
Date: Tue, 4 Apr 2006 00:05:52 -0500
User-agent: Mutt/1.5.6i

On Mon, Apr 03, 2006 at 06:55:30PM +0200, Ralf Wildenhues wrote:
> Hi Albert,
> 
> * Albert Chin wrote on Fri, Mar 31, 2006 at 10:40:14PM CEST:
> > On Fri, Mar 31, 2006 at 02:25:51PM -0600, Albert Chin wrote:
> > > Autoconf 2.59 chooses __restrict on HP-UX 11.x.
> 
> > typedef int * int_ptr;
> > 
> > void
> > foo (int_ptr __restrict rp) {
> >   int i;
> > }
> >   $ cc -c a.c
> > cc: "a.c", line 4: error 1671: Illegal use of restrict.
> > 
> > If I replace the parameter list with "int *" rather than "int_ptr",
> > then it works. Compiler bug?
> 
> I think so.  Probably a good idea to check this in _AC_PROG_CC_C99 as
> well.  While at it, let's remove the `unused variable' warnings so this
> works with -Werror.

According to HP, "Since C99 isn't fully supported on PA ...". Anyway,
I'll submit a compiler bug and we'll see if it gets fixed.

> AC_C_RESTRICT also suffers from the cleanup buglet mentioned a couple of
> days ago, as well as AC_C_INLINE.  I noticed furthermore that neither of
> these macros is tested by the testsuite.
> 
> OK to apply this patch to address all of this?

Thanks.

> Cheers,
> Ralf
> 
>       * lib/autoconf/c.m4 (AC_C_INLINE): Do not skip cleanup code.
>         (AC_C_RESTRICT): Likewise.  Furthermore, add a function with a
>       typedef'ed restricted pointer, to catch a compiler bug on
>       HP-UX 11.x, and fix warnings so it passes with -Werror.
>       (_AC_PROG_CC_C99): Likewise.
>       Reported by Albert Chin <address@hidden>.
>       * tests/mktests.sh: Do not skip AC_C_INLINE, AC_C_RESTRICT.
> 
> Index: lib/autoconf/c.m4
> ===================================================================
> RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
> retrieving revision 1.217
> diff -u -r1.217 c.m4
> --- lib/autoconf/c.m4 3 Apr 2006 03:18:39 -0000       1.217
> +++ lib/autoconf/c.m4 3 Apr 2006 16:51:26 -0000
> @@ -1092,8 +1092,10 @@
>    double average;
>  };
>  
> +typedef const char *ccp;
> +
>  static inline int
> -test_restrict(const char *restrict text)
> +test_restrict(ccp restrict text)
>  {
>    // See if C++-style comments work.
>    // Iterate through items via the restricted pointer.
> @@ -1169,6 +1171,9 @@
>  
>    int dynamic_array[ni.number];
>    dynamic_array[43] = 543;
> +
> +  // work around unused variable warnings
> +  return  bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x';
>  ]],
>  dnl Try
>  dnl GCC              -std=gnu99 (unused restrictive modes: -std=c99 
> -std=iso9899:1999)
> @@ -1397,7 +1381,8 @@
>  $ac_kw foo_t foo () {return 0; }
>  #endif
>  ])],
> -                 [ac_cv_c_inline=$ac_kw; break])
> +                 [ac_cv_c_inline=$ac_kw])
> +  test "$ac_cv_c_inline" != no && break
>  done
>  ])
>  AH_VERBATIM([inline],
> @@ -1505,9 +1490,17 @@
>     # Try the official restrict keyword, then gcc's __restrict, and
>     # the less common variants.
>     for ac_kw in restrict __restrict __restrict__ _Restrict; do
> -     AC_COMPILE_IFELSE([AC_LANG_SOURCE(
> -      [float * $ac_kw x;])],
> -      [ac_cv_c_restrict=$ac_kw; break])
> +     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_cv_c_restrict=$ac_kw])
> +     test "$ac_cv_c_restrict" != no && break
>     done
>    ])
>   case $ac_cv_c_restrict in
> Index: tests/mktests.sh
> ===================================================================
> RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
> retrieving revision 1.45
> diff -u -r1.45 mktests.sh
> --- tests/mktests.sh  1 Apr 2006 15:57:02 -0000       1.45
> +++ tests/mktests.sh  3 Apr 2006 16:40:05 -0000
> @@ -121,7 +121,7 @@
>  # - AC_FD_CC
>  #   Is a number.
>  #
> -# - AC_PROG_CC, AC_C_(CONST|INLINE|VOLATILE), AC_PATH_XTRA
> +# - AC_PROG_CC, AC_C_(CONST|VOLATILE), AC_PATH_XTRA
>  #   Checked in semantics.
>  #
>  # - AC_CYGWIN, AC_CYGWIN32, AC_EMXOS2, AC_MING32, AC_EXEEXT, AC_OBJEXT
> @@ -155,7 +155,7 @@
>  ^AC_SEARCH_LIBS$
>  ^(AC_TRY.*|AC_RUN_LOG)$
>  ^AC_.*_IFELSE$
> -^(AC_(PROG_CC|C_CONST|C_INLINE|C_RESTRICT|C_VOLATILE))$
> +^(AC_(PROG_CC|C_CONST|C_VOLATILE))$
>  ^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$
>  ^AC_PATH_XTRA$
>  ^AC_SYS_RESTARTABLE_SYSCALLS$
> 
> 
> _______________________________________________
> Autoconf mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/autoconf
> 
> 

-- 
albert chin (address@hidden)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]