aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support/ChangeLog4
-rw-r--r--support/dfa.c24
-rw-r--r--support/dfa.h2
-rw-r--r--support/intprops.h79
-rw-r--r--support/verify.h9
5 files changed, 59 insertions, 59 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index 1c6015f3..e2077bd0 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * dfa.c, dfa.h, intprops.h, verify.h: Sync with GNULIB.
+
2017-03-23 Arnold D. Robbins <arnold@skeeve.com>
* dfa.c: Sync with GNULIB.
diff --git a/support/dfa.c b/support/dfa.c
index 2003ac55..18c17a5d 100644
--- a/support/dfa.c
+++ b/support/dfa.c
@@ -72,6 +72,14 @@ isasciidigit (char c)
#include "xalloc.h"
#include "localeinfo.h"
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
@@ -1661,10 +1669,10 @@ addtok_mb (struct dfa *dfa, token t, char mbprop)
case BACKREF:
dfa->fast = false;
- /* fallthrough */
+ FALLTHROUGH;
default:
dfa->nleaves++;
- /* fallthrough */
+ FALLTHROUGH;
case EMPTY:
dfa->parse.depth++;
break;
@@ -2461,8 +2469,7 @@ dfaanalyze (struct dfa *d, bool searchflag)
copy (&merged, &d->follows[pos[j].index]);
}
}
- /* fallthrough */
-
+ FALLTHROUGH;
case QMARK:
/* A QMARK or STAR node is automatically nullable. */
if (d->tokens[i] != PLUS)
@@ -2752,13 +2759,13 @@ build_state (state_num s, struct dfa *d, unsigned char uc)
else if (d->tokens[pos.index] >= CSET)
{
matches = d->charclasses[d->tokens[pos.index] - CSET];
- if (tstbit (uc, &d->charclasses[d->tokens[pos.index] - CSET]))
+ if (tstbit (uc, &matches))
matched = true;
}
else if (d->tokens[pos.index] == ANYCHAR)
{
matches = d->charclasses[d->canychar];
- if (tstbit (uc, &d->charclasses[d->canychar]))
+ if (tstbit (uc, &matches))
matched = true;
/* ANYCHAR must match with a single character, so we must put
@@ -3378,8 +3385,7 @@ dfa_supported (struct dfa const *d)
case NOTLIMWORD:
if (!d->localeinfo.multibyte)
continue;
- /* fallthrough */
-
+ FALLTHROUGH;
case BACKREF:
case MBCSET:
return false;
@@ -3488,7 +3494,7 @@ dfassbuild (struct dfa *d)
sup->tokens[j++] = EMPTY;
break;
}
- /* fallthrough */
+ FALLTHROUGH;
default:
sup->tokens[j++] = d->tokens[i];
if ((0 <= d->tokens[i] && d->tokens[i] < NOTCHAR)
diff --git a/support/dfa.h b/support/dfa.h
index c68b4df7..7d11f05d 100644
--- a/support/dfa.h
+++ b/support/dfa.h
@@ -1,5 +1,5 @@
/* dfa.h - declarations for GNU deterministic regexp compiler
- Copyright (C) 1988, 1998, 2007, 2009-2016 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1998, 2007, 2009-2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/support/intprops.h b/support/intprops.h
index 716741ad..d8c71206 100644
--- a/support/intprops.h
+++ b/support/intprops.h
@@ -1,6 +1,6 @@
/* intprops.h -- properties of integer types
- Copyright (C) 2001-2016 Free Software Foundation, Inc.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@@ -21,11 +21,6 @@
#define _GL_INTPROPS_H
#include <limits.h>
-#include <verify.h>
-
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
/* Return a value with the common real type of E and V and the value of V. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
@@ -84,24 +79,7 @@
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
- As a sanity check, test the assumption for some signed types that
- <limits.h> bounds. */
-verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
-verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
-verify (TYPE_MINIMUM (short int) == SHRT_MIN);
-verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
-verify (TYPE_MINIMUM (int) == INT_MIN);
-verify (TYPE_MAXIMUM (int) == INT_MAX);
-verify (TYPE_MINIMUM (long int) == LONG_MIN);
-verify (TYPE_MAXIMUM (long int) == LONG_MAX);
-#ifdef LLONG_MAX
-verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
-verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
-#endif
-/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
-#ifdef UINT_WIDTH
-verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
-#endif
+ This assumption is tested by the intprops-tests module. */
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
@@ -241,12 +219,10 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
: (max) >> (b) < (a))
/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#define _GL_HAS_BUILTIN_OVERFLOW \
- (5 <= __GNUC__ || __has_builtin (__builtin_add_overflow))
+#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
/* True if __builtin_add_overflow_p (A, B, C) works. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P \
- (7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p))
+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
@@ -395,10 +371,10 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
(_Generic \
(*(r), \
signed char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
signed char, SCHAR_MIN, SCHAR_MAX), \
short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
short int, SHRT_MIN, SHRT_MAX), \
int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
@@ -412,10 +388,10 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
#else
# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
(sizeof *(r) == sizeof (signed char) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
signed char, SCHAR_MIN, SCHAR_MAX) \
: sizeof *(r) == sizeof (short int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
short int, SHRT_MIN, SHRT_MAX) \
: sizeof *(r) == sizeof (int) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
@@ -437,9 +413,8 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
/* Store the low-order bits of A <op> B into *R, where the operation
is given by OP. Use the unsigned type UT for calculation to avoid
- overflow problems. *R's type is T, with extremal values TMIN and
- TMAX. T must be a signed integer type. Return 1 if the result
- overflows. */
+ overflow problems. *R's type is T, with extrema TMIN and TMAX.
+ T must be a signed integer type. Return 1 if the result overflows. */
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
(sizeof ((a) op (b)) < sizeof (t) \
? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
@@ -448,17 +423,27 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
((overflow (a, b) \
|| (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
|| (tmax) < ((a) op (b))) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
-
-/* Return A <op> B, where the operation is given by OP. Use the
- unsigned type UT for calculation to avoid overflow problems.
- Convert the result to type T without overflow by subtracting TMIN
- from large values before converting, and adding it afterwards.
- Compilers can optimize all the operations except OP. */
-#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
- (((ut) (a) op (ut) (b)) <= (tmax) \
- ? (t) ((ut) (a) op (ut) (b)) \
- : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
+
+/* Return the low-order bits of A <op> B, where the operation is given
+ by OP. Use the unsigned type UT for calculation to avoid undefined
+ behavior on signed integer overflow, and convert the result to type T.
+ UT is at least as wide as T and is no narrower than unsigned int,
+ T is two's complement, and there is no padding or trap representations.
+ Assume that converting UT to T yields the low-order bits, as is
+ done in all known two's-complement C compilers. E.g., see:
+ https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
+
+ According to the C standard, converting UT to T yields an
+ implementation-defined result or signal for values outside T's
+ range. However, code that works around this theoretical problem
+ runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
+ http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
+ As the compiler bug is real, don't try to work around the
+ theoretical problem. */
+
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
+ ((t) ((ut) (a) op (ut) (b)))
#endif /* _GL_INTPROPS_H */
diff --git a/support/verify.h b/support/verify.h
index 5c8381d2..dcba9c8c 100644
--- a/support/verify.h
+++ b/support/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2016 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -248,7 +248,12 @@ template <int w>
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. */
-#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#ifdef __GNUC__
+# define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#else
+/* PGI barfs if R is long. Play it safe. */
+# define verify(R) _GL_VERIFY (R, "verify (...)")
+#endif
#ifndef __has_builtin
# define __has_builtin(x) 0