diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2019-05-22 20:05:05 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2019-05-22 20:05:05 +0300 |
commit | 990649951e7fa34ae589a19ac686ffcc655d584b (patch) | |
tree | 70f8725186e548415c536ae8193fd55bb52968d9 | |
parent | 63dafc1ea7696ea3383f970fc7eabc5f939b56ae (diff) | |
download | egawk-990649951e7fa34ae589a19ac686ffcc655d584b.tar.gz egawk-990649951e7fa34ae589a19ac686ffcc655d584b.tar.bz2 egawk-990649951e7fa34ae589a19ac686ffcc655d584b.zip |
Sync support files with GNULIB.
-rw-r--r-- | support/ChangeLog | 4 | ||||
-rw-r--r-- | support/cdefs.h | 2 | ||||
-rw-r--r-- | support/dfa.c | 7 | ||||
-rw-r--r-- | support/dfa.h | 8 | ||||
-rw-r--r-- | support/verify.h | 110 |
5 files changed, 66 insertions, 65 deletions
diff --git a/support/ChangeLog b/support/ChangeLog index 3824197e..9333db77 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,7 @@ +2019-05-22 Arnold D. Robbins <arnold@skeeve.com> + + * cdefs.h, dfa.h, dfa.c, verify.h: Sync from GNULIB. + 2019-04-23 Arnold D. Robbins <arnold@skeeve.com> * regcomp.c, regex_internal.h: Sync from GNULIB. diff --git a/support/cdefs.h b/support/cdefs.h index 20ee75db..4f921754 100644 --- a/support/cdefs.h +++ b/support/cdefs.h @@ -198,7 +198,7 @@ `__attribute__' syntax. All of the ways we use this do fine if they are omitted for compilers that don't understand it. */ #if !defined __GNUC__ || __GNUC__ < 2 -# define __attribute__(arg) /* Ignore */ +# define __attribute__(xyz) /* Ignore */ #endif /* At some point during the gcc 2.96 development the `malloc' attribute diff --git a/support/dfa.c b/support/dfa.c index 88c9a231..fec637a6 100644 --- a/support/dfa.c +++ b/support/dfa.c @@ -262,6 +262,7 @@ enum comparisons to END. */ /* Ordinary character values are terminal symbols that match themselves. */ + /* CSET must come last in the following list of special tokens. Otherwise, the list order matters only for performance. Related special tokens should have nearby values so that code like (t == ANYCHAR || t == MBCSET @@ -301,9 +302,11 @@ enum WCHAR, /* Only returned by lex. wctok contains the wide character representation. */ + ANYCHAR, /* ANYCHAR is a terminal symbol that matches a valid multibyte (or single byte) character. It is used only if MB_CUR_MAX > 1. */ + BEG, /* BEG is an initial symbol that matches the beginning of input. */ @@ -340,7 +343,6 @@ enum MBCSET, /* MBCSET is similar to CSET, but for multibyte characters. */ - CSET /* CSET and (and any value greater) is a terminal symbol that matches any of a class of characters. */ @@ -2365,6 +2367,7 @@ charclass_context (struct dfa const *dfa, charclass const *c) return context; } + /* Returns the contexts on which the position set S depends. Each context in the set of returned contexts (let's call it SC) may have a different follow set than other contexts in SC, and also different from the @@ -2837,7 +2840,6 @@ dfaanalyze (struct dfa *d, bool searchflag) } #endif - pos.index = 0; pos.constraint = NO_CONSTRAINT; @@ -3163,7 +3165,6 @@ build_state (state_num s, struct dfa *d, unsigned char uc) /* Find the state(s) corresponding to the union of the follows. */ if (possible_contexts & ~separate_contexts) state = state_index (d, &group, separate_contexts ^ CTX_ANY); - else state = -1; if (separate_contexts & possible_contexts & CTX_NEWLINE) diff --git a/support/dfa.h b/support/dfa.h index 2cf11b6b..2e25ef9f 100644 --- a/support/dfa.h +++ b/support/dfa.h @@ -22,12 +22,6 @@ #include <stdbool.h> #include <stddef.h> -#if 3 <= __GNUC__ -# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -#else -# define _GL_ATTRIBUTE_MALLOC -#endif - struct localeinfo; /* See localeinfo.h. */ /* Element of a list of strings, at least one of which is known to @@ -48,7 +42,7 @@ struct dfa; /* Allocate a struct dfa. The struct dfa is completely opaque. The returned pointer should be passed directly to free() after calling dfafree() on it. */ -extern struct dfa *dfaalloc (void) _GL_ATTRIBUTE_MALLOC; +extern struct dfa *dfaalloc (void) /* _GL_ATTRIBUTE_MALLOC */; /* DFA options that can be ORed together, for dfasyntax's 4th arg. */ enum diff --git a/support/verify.h b/support/verify.h index 6930645a..f8e4eff0 100644 --- a/support/verify.h +++ b/support/verify.h @@ -21,29 +21,37 @@ #define _GL_VERIFY_H -/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. - This is supported by GCC 4.6.0 and later, in C mode, and its use - here generates easier-to-read diagnostics when verify (R) fails. - - Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. - This is supported by GCC 6.1.0 and later, in C++ mode. - - 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__ + (6 <= __GNUC_MINOR__) \ - && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ - && !defined __cplusplus) -# define _GL_HAVE__STATIC_ASSERT 1 -#endif -#if (6 <= __GNUC__) && defined __cplusplus -# define _GL_HAVE_STATIC_ASSERT 1 +/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC) + works as per C11. This is supported by GCC 4.6.0 and later, in C + mode. + + Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as + per C2X, and define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) + works as per C++17. This is supported by GCC 9.1 and later. + + Support compilers claiming conformance to the relevant standard, + and also support GCC when not pedantic. 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? */ +#ifndef __cplusplus +# if (201112L <= __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__))) +# define _GL_HAVE__STATIC_ASSERT 1 +# endif +# if (202000L <= __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) +# define _GL_HAVE__STATIC_ASSERT1 1 +# endif +#else +# if 201703L <= __cplusplus || 9 <= __GNUC__ +# define _GL_HAVE_STATIC_ASSERT1 1 +# endif #endif /* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other system headers, defines a conflicting _Static_assert that is no better than ours; override it. */ -#ifndef _GL_HAVE_STATIC_ASSERT +#ifndef _GL_HAVE__STATIC_ASSERT # include <stddef.h> # undef _Static_assert #endif @@ -141,9 +149,9 @@ which do not support _Static_assert, also do not warn about the last declaration mentioned above. - * GCC warns if -Wnested-externs is enabled and verify() is used + * GCC warns if -Wnested-externs is enabled and 'verify' is used within a function body; but inside a function, you can always - arrange to use verify_expr() instead. + arrange to use verify_expr instead. * In C++, any struct definition inside sizeof is invalid. Use a template type to work around the problem. */ @@ -167,11 +175,9 @@ #define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) /* Verify requirement R at compile-time, as an integer constant expression - that returns 1. If R is false, fail at compile-time, preferably - with a diagnostic that includes the string-literal DIAGNOSTIC. */ + that returns 1. If R is false, fail at compile-time. */ -#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ - (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) +#define _GL_VERIFY_TRUE(R) (!!sizeof (_GL_VERIFY_TYPE (R))) #ifdef __cplusplus # if !GNULIB_defined_struct__gl_verify_type @@ -181,40 +187,43 @@ template <int w> }; # define GNULIB_defined_struct__gl_verify_type 1 # endif -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - _gl_verify_type<(R) ? 1 : -1> -#elif defined _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ +# define _GL_VERIFY_TYPE(R) _gl_verify_type<(R) ? 1 : -1> +#elif defined _GL_HAVE__STATIC_ASSERT1 +# define _GL_VERIFY_TYPE(R) \ struct { \ - _Static_assert (R, DIAGNOSTIC); \ + _Static_assert (R); \ int _gl_dummy; \ } #else -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ +# define _GL_VERIFY_TYPE(R) \ struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } #endif /* Verify requirement R at compile-time, as a declaration without a - trailing ';'. If R is false, fail at compile-time, preferably - with a diagnostic that includes the string-literal DIAGNOSTIC. + trailing ';'. If R is false, fail at compile-time. + + This macro requires three or more arguments but uses at most the first + two, so that the _Static_assert macro optionally defined below supports + both the C11 two-argument syntax and the C2X one-argument syntax. Unfortunately, unlike C11, this implementation must appear as an ordinary declaration, and cannot appear inside struct { ... }. */ -#ifdef _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY _Static_assert +#if defined _GL_HAVE__STATIC_ASSERT +# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) #else -# define _GL_VERIFY(R, DIAGNOSTIC) \ +# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ - [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] + [_GL_VERIFY_TRUE (R)] #endif /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ #ifdef _GL_STATIC_ASSERT_H -# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert -# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) +# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert +# define _Static_assert(...) \ + _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) # endif -# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert +# if !defined _GL_HAVE_STATIC_ASSERT1 && !defined static_assert # define static_assert _Static_assert /* C11 requires this #define. */ # endif #endif @@ -226,31 +235,24 @@ template <int w> assert (R), there is no run-time overhead. There are two macros, since no single macro can be used in all - contexts in C. verify_true (R) is for scalar contexts, including + contexts in C. verify_expr (R, E) is for scalar contexts, including integer constant expression contexts. verify (R) is for declaration contexts, e.g., the top level. */ -/* Verify requirement R at compile-time, as an integer constant expression. - Return 1. This is equivalent to verify_expr (R, 1). - - verify_true is obsolescent; please use verify_expr instead. */ - -#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") - /* Verify requirement R at compile-time. Return the value of the expression E. */ -#define verify_expr(R, E) \ - (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) +#define verify_expr(R, E) (_GL_VERIFY_TRUE (R) ? (E) : (E)) /* Verify requirement R at compile-time, as a declaration without a - trailing ';'. */ + trailing ';'. verify (R) acts like static_assert (R) except that + it is portable to C11/C++14 and earlier, and its name is shorter + and may be more convenient. */ -#ifdef __GNUC__ -# define verify(R) _GL_VERIFY (R, "verify (" #R ")") +#ifdef _GL_HAVE__STATIC_ASSERT1 +# define verify(R) _Static_assert (R) #else -/* PGI barfs if R is long. Play it safe. */ -# define verify(R) _GL_VERIFY (R, "verify (...)") +# define verify(R) _GL_VERIFY (R, "verify (...)", -) #endif #ifndef __has_builtin |