From: Paul Eggert Date: Mon, 27 Nov 2006 07:15:26 +0000 (+0000) Subject: Fix some incompatibilities with gcc -ansi -pedantic. X-Git-Tag: cvs-readonly~1529 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=564569a4dffe68422c48b486a2e0f377bb4a048d;p=gnulib.git Fix some incompatibilities with gcc -ansi -pedantic. * lib/regex.h (__restrict_arr): Don't use the [restrict] syntax if compiling pedantically with GCC, unless it's C99 or later. Don't trust sys/cdefs.h's definition of __restrict_arr, either, as it mishandles gcc -ansi -pedantic as well. * lib/regex_internal.h (re_token_t): Don't use enum bitfields if gcc -pedantic. * lib/regexec.c (check_node_accept_bytes): Don't use auto initializers for struct if -pedantic, unless it's C99 or later. --- diff --git a/ChangeLog b/ChangeLog index e1c6dcfb8..3fa63a716 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-11-26 Paul Eggert + + Fix some incompatibilities with gcc -ansi -pedantic. + * lib/regex.h (__restrict_arr): Don't use the [restrict] syntax + if compiling pedantically with GCC, unless it's C99 or later. + Don't trust sys/cdefs.h's definition of __restrict_arr, either, as + it mishandles gcc -ansi -pedantic as well. + * lib/regex_internal.h (re_token_t): Don't use enum bitfields + if gcc -pedantic. + * lib/regexec.c (check_node_accept_bytes): Don't use auto + initializers for struct if -pedantic, unless it's C99 or later. + 2006-11-25 Nix (tiny change) * m4/fcntl_h.m4 (gl_FCNTL_H): Test the atime, not the mtime. diff --git a/lib/regex.h b/lib/regex.h index e8748e195..621bffb51 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -635,14 +635,17 @@ extern int re_exec (const char *); # endif # endif #endif -/* gcc 3.1 and up support the [restrict] syntax. */ -#ifndef __restrict_arr -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \ - && !defined __GNUG__ -# define __restrict_arr __restrict -# else -# define __restrict_arr -# endif +/* gcc 3.1 and up support the [restrict] syntax. Don't trust + sys/cdefs.h's definition of __restrict_arr, though, as it + mishandles gcc -ansi -pedantic. */ +#undef __restrict_arr +#if (defined __GNUG__ \ + || (__STDC_VERSION__ < 199901L \ + && (__STRICT_ANSI__ \ + || (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1))))) +# define __restrict_arr +#else +# define __restrict_arr __restrict #endif /* POSIX compatibility. */ diff --git a/lib/regex_internal.h b/lib/regex_internal.h index cc9b5b79c..9a978b2a9 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -348,7 +348,7 @@ typedef struct Idx idx; /* for BACK_REF */ re_context_type ctx_type; /* for ANCHOR */ } opr; -#if __GNUC__ >= 2 +#if __GNUC__ >= 2 && !__STRICT_ANSI__ re_token_type_t type : 8; #else re_token_type_t type; diff --git a/lib/regexec.c b/lib/regexec.c index 84c3aed63..7c186aa20 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -3966,7 +3966,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, # endif /* _LIBC */ { /* match with range expression? */ -#if __GNUC__ >= 2 +#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && __STRICT_ANSI__) wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'}; #else wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};