2020-05-03 Paul Eggert <eggert@cs.ucla.edu>
attribute: new module
- This simplifies use of GCC and C2X attributes like ‘deprecated’.
+ This simplifies use of GCC and C2x attributes like ‘deprecated’.
* MODULES.html.sh: Add attribute.
* doc/attribute.texi, lib/attribute.h, modules/attribute: New files.
* doc/gnulib.texi (Particular Modules): Add Attributes.
Include attribute.h, and let it define FALLTHROUGH.
* lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro.
* lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of
- _GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X.
+ _GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2x.
* lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY.
This is a copy since Gawk doesn’t use Gnulib.
* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that
* lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h:
* lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed
__attribute__ ((__warn_unused_result__)), for forward
- compatibility to C2X.
+ compatibility to C2x.
* lib/hash.h (_GL_ATTRIBUTE_WUR): Remove. All uses replaced by
_GL_ATTRIBUTE_NODISCARD.
(_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it.
* lib/verify.h (verify_true): Remove.
* tests/test-verify.c (item): Test verify_expr, not verify_true.
- Support C2X and C++17 static_assert
- C2X and C++17 finally added support for a simple, single-argument
+ Support C2x and C++17 static_assert
+ C2x and C++17 finally added support for a simple, single-argument
‘static_assert’ that implements what the Gnulib ‘verify’ macro was
doing back in 2005. Implement static_assert on older platforms.
The only remaining advantage of ‘verify’ is a shorter name.
* doc/posix-headers/assert.texi (assert.h):
* doc/verify.texi (Compile-time Assertions):
- Modernize for C2X and C++17.
+ Modernize for C2x and C++17.
* lib/verify.h (_GL_HAVE__STATIC_ASSERT1, _GL_HAVE_STATIC_ASSERT1):
New macros.
(_GL_HAVE__STATIC_ASSERT): Remove.
@noindent
@code{NODISCARD} expands to @code{[[nodiscard]]} if the compiler
-supports this C2X syntax, otherwise to
+supports this C2x syntax, otherwise to
@code{__attribute__ ((__warn_unused_result__))} if the compiler
is a recent-enough GCC or GCC-like compiler, otherwise to nothing.
@code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
recent-enough GCC, and to nothing otherwise.
Most of these attribute names begin with @code{ATTRIBUTE_}.
-A few do not, because they are part of C2X and their
+A few do not, because they are part of C2x and their
names are not likely to clash with other macro names.
These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
@code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
-be defined to @code{[[deprecated]]} etc.@: on C2X platforms.
+be defined to @code{[[deprecated]]} etc.@: on C2x platforms.
Also, these exceptional macros should be placed at the start of
function declarations, whereas the @code{ATTRIBUTE_*} macros can be
placed at the end.
On older platforms @code{static_assert} and @code{_Static_assert} do
not allow the second string-literal argument to be omitted. For
example, GCC versions before 9.1 do not support the single-argument
-@code{static_assert} that was standardized by C2X and C++17.
+@code{static_assert} that was standardized by C2x and C++17.
@item
Even-older platforms do not support @code{static_assert} or
@code{_Static_assert} at all. For example, GCC versions before 4.6 do
@samp{verify (@var{V});} even when @var{V} is
nonzero.
-Although the standard @code{assert} macro is a runtime test, C2X
+Although the standard @code{assert} macro is a runtime test, C2x
specifies a builtin @code{_Static_assert (@var{V})},
its @file{assert.h} header has a similar macro
named @code{static_assert}, and C++17 has a similar
ordinary member declaration. Second, they allow the programmer to
specify, as an optional second argument, a compile-time diagnostic as
a string literal. If your program is not intended to be portable to
-compilers that lack C2X or C++17 @code{static_assert}, the only
+compilers that lack C2x or C++17 @code{static_assert}, the only
advantage of @code{verify} is that its name is a bit shorter.
The @file{verify.h} header defines one more macro, @code{assume
/* This file defines two types of attributes:
- * C2X standard attributes. These have macro names that do not begin with
+ * C2x standard attributes. These have macro names that do not begin with
'ATTRIBUTE_'.
* Selected GCC attributes; see:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
- per C2X. This is supported by GCC 9.1+.
+ per C2x. This is supported by GCC 9.1+.
Support compilers claiming conformance to the relevant standard,
and also support GCC when not pedantic. If we were willing to slow
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.
+ 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 { ... }. */