>From e3665e43f2a042b26fa65cdba80dd89846d95540 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 10 Oct 2020 11:48:16 -0700 Subject: [PATCH] attribute: improve const, pure doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem reported by Marc Nieper-Wißkirchen in: https://lists.gnu.org/r/bug-gnulib/2020-10/msg00035.html * lib/attribute.h (ATTRIBUTE_CONST, ATTRIBUTE_PURE): Improv doc. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51971#c1 --- ChangeLog | 8 ++++++++ lib/attribute.h | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 875f3551a..b479cf0c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-10-10 Paul Eggert + + attribute: improve const, pure doc + Problem reported by Marc Nieper-Wißkirchen in: + https://lists.gnu.org/r/bug-gnulib/2020-10/msg00035.html + * lib/attribute.h (ATTRIBUTE_CONST, ATTRIBUTE_PURE): Improv doc. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51971#c1 + 2020-10-05 Paul Eggert thread: pacify GCC on Solaris 10 diff --git a/lib/attribute.h b/lib/attribute.h index b97514655..48d9826c8 100644 --- a/lib/attribute.h +++ b/lib/attribute.h @@ -170,18 +170,21 @@ /* Applies to: function. */ #define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE -/* The function does not affect observable state, and always returns a value. - Compilers can omit duplicate calls with the same arguments if - observable state is not changed between calls. (This attribute is - looser than ATTRIBUTE_CONST.) */ +/* It is OK for a compiler to omit duplicate calls with the same arguments. + This attribute is safe for a function that neither depends on + nor affects observable state, and always returns exactly once - + e.g., does not loop forever, and does not call longjmp. + (This attribute is stricter than ATTRIBUTE_PURE.) */ /* Applies to: functions. */ -#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE +#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST -/* The function neither depends on nor affects observable state, - and always returns a value. Compilers can omit duplicate calls with - the same arguments. (This attribute is stricter than ATTRIBUTE_PURE.) */ +/* It is OK for a compiler to omit duplicate calls with the same + arguments if observable state is not changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than ATTRIBUTE_CONST.) */ /* Applies to: functions. */ -#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST +#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE /* The function is rarely executed. */ /* Applies to: functions. */ -- 2.25.1