]> Savannah Git Hosting - gnulib.git/commitdiff
c-ctype, regex, verify: port to gcc -std=c90 -pedantic
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 30 May 2013 01:48:09 +0000 (18:48 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 30 May 2013 01:50:54 +0000 (18:50 -0700)
Avoid constructions that are rejected by gcc -std=c90 -pedantic.
This fixes a porting bug I recently reintroduced in regex, and
some other instances that I discovered while testing the fix.
* lib/c-ctype.h [__STRICT_ANSI__]: Avoid ({ ... }).
* lib/regcomp.c (utf8_sb_map) [__STRICT_ANSI__]: Avoid [0 ... N] = E.
* lib/regex_internal.h [!_LIBC && GNULIB_LOCK]: Do not use a macro
with an empty argument if this is a pedantic pre-C99 GCC.
* lib/verify.h: Do not use _Static_assert if this is a pedantic
pre-C11 GCC.

ChangeLog
lib/c-ctype.h
lib/regcomp.c
lib/regex_internal.h
lib/verify.h

index 8097562ed119b5565b37b6bfc26a26ad7bb0629e..6cfb46b333c61c93cbd7e0bc44c9cdc25320975c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2013-05-29  Paul Eggert  <eggert@cs.ucla.edu>
 
+       c-ctype, regex, verify: port to gcc -std=c90 -pedantic
+       Avoid constructions that are rejected by gcc -std=c90 -pedantic.
+       This fixes a porting bug I recently reintroduced in regex, and
+       some other instances that I discovered while testing the fix.
+       * lib/c-ctype.h [__STRICT_ANSI__]: Avoid ({ ... }).
+       * lib/regcomp.c (utf8_sb_map) [__STRICT_ANSI__]: Avoid [0 ... N] = E.
+       * lib/regex_internal.h [!_LIBC && GNULIB_LOCK]: Do not use a macro
+       with an empty argument if this is a pedantic pre-C99 GCC.
+       * lib/verify.h: Do not use _Static_assert if this is a pedantic
+       pre-C11 GCC.
+
        regex: adapt to locking regime instead of depending on pthread
        Instead of depending on pthread, adapt to whatever thread
        modules are in use.  Problem reported by Ludovic Courtès in
index 36144b8a09df831463a1a07a11840f5762578334..5347d344e0f321072bdf59b35a60695b930d0d06 100644 (file)
@@ -136,7 +136,8 @@ extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
 extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
 
 
-#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
+#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \
+     && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS)
 
 /* ASCII optimizations. */
 
index 534438169ff1e75eba9ad0e754f6c94ca1b00cb5..4de2ed2d8135f022036489a96e4062af0d033fdf 100644 (file)
@@ -586,7 +586,7 @@ weak_alias (__regerror, regerror)
 static const bitset_t utf8_sb_map =
 {
   /* Set the first 128 bits.  */
-# ifdef __GNUC__
+# if defined __GNUC__ && !defined __STRICT_ANSI__
   [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
 # else
 #  if 4 * BITSET_WORD_BITS < ASCII_CHARS
index 0f917e66e0dcf6237c7a796cf9de737da7ba026d..c92fb1a385a0cee4d0211e723726ade17321e6bc 100644 (file)
 # define lock_unlock(lock) __libc_lock_unlock (lock)
 #elif defined GNULIB_LOCK
 # include "glthread/lock.h"
-# define lock_define(name) gl_lock_define (, name)
+  /* Use gl_lock_define if empty macro arguments are known to work.
+     Otherwise, fall back on less-portable substitutes.  */
+# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
+      || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
+#  define lock_define(name) gl_lock_define (, name)
+# elif USE_POSIX_THREADS
+#  define lock_define(name) pthread_mutex_t name;
+# elif USE_PTH_THREADS
+#  define lock_define(name) pth_mutex_t name;
+# elif USE_SOLARIS_THREADS
+#  define lock_define(name) mutex_t name;
+# elif USE_WINDOWS_THREADS
+#  define lock_define(name) gl_lock_t name;
+# else
+#  define lock_define(name)
+# endif
 # define lock_init(lock) glthread_lock_init (&(lock))
 # define lock_fini(lock) glthread_lock_destroy (&(lock))
 # define lock_lock(lock) glthread_lock_lock (&(lock))
index cb8e90b5427e4382805c1ebfac2101b78790cad4..03492efcd3f4a5c2beaafb5ba8ea372f4ece957f 100644 (file)
@@ -31,7 +31,9 @@
    Use this only with GCC.  If we were willing to slow 'configure'
    down we could also use it with other compilers, but since this
    affects only the quality of diagnostics, why bother?  */
-# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
+# if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
+      && (201112L <= __STDC_VERSION__  || !defined __STRICT_ANSI__) \
+      && !defined __cplusplus)
 #  define _GL_HAVE__STATIC_ASSERT 1
 # endif
 /* The condition (99 < __GNUC__) is temporary, until we know about the