Fix some incompatibilities with gcc -ansi -pedantic.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 27 Nov 2006 07:15:26 +0000 (07:15 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 27 Nov 2006 07:15:26 +0000 (07:15 +0000)
* 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.

ChangeLog
lib/regex.h
lib/regex_internal.h
lib/regexec.c

index e1c6dcf..3fa63a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-11-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <nix@esperi.org.uk>  (tiny change)
 
        * m4/fcntl_h.m4 (gl_FCNTL_H): Test the atime, not the mtime.
index e8748e1..621bffb 100644 (file)
@@ -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.  */
index cc9b5b7..9a978b2 100644 (file)
@@ -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;
index 84c3aed..7c186aa 100644 (file)
@@ -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'};