]> Savannah Git Hosting - gnulib.git/commitdiff
error: Improve comments.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Jun 2023 09:59:59 +0000 (11:59 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Jun 2023 09:59:59 +0000 (11:59 +0200)
* lib/error.in.h (__gl_error_call): Add more comments.

ChangeLog
lib/error.in.h

index fda2ed0e3f6dbca99ee09c215a096c930e54ad86..31f76abd4a25b6af466d276dfa740ce818e59307 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-06-03  Bruno Haible  <bruno@clisp.org>
+
+       error: Improve comments.
+       * lib/error.in.h (__gl_error_call): Add more comments.
+
 2023-06-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        error: do not evaluate status twice
index 279258f63e977f2af564bd11aad43f7172f2bad0..ef4b3c38150a3c00c490a20f12dc03fb24851aa6 100644 (file)
 #endif
 
 /* Helper macro for supporting the compiler's control flow analysis better.
-   It evaluates its arguments only once.  It uses __builtin_constant_p
-   and comma expressions to work around GCC false positives.
+   It evaluates its arguments only once.
    Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough".  */
 #ifdef __GNUC__
+/* Use 'unreachable' to tell the compiler when the function call does not
+   return.  */
 # define __gl_error_call1(function, status, ...) \
     ((function) (status, __VA_ARGS__), \
      (status) != 0 ? unreachable () : (void) 0)
+/* If STATUS is a not a constant, the function call may or may not return;
+   therefore -Wimplicit-fallthrough will produce a warning.  Use a compound
+   statement in order to evaluate STATUS only once.
+   If STATUS is a constant, we don't use a compound statement, because that
+   would trigger a -Wimplicit-fallthrough warning even when STATUS is != 0,
+   when not optimizing.  This causes STATUS to be evaluated twice, but
+   that's OK since it does not have side effects.  */
 # define __gl_error_call(function, status, ...) \
     (__builtin_constant_p (status) \
      ? __gl_error_call1 (function, status, __VA_ARGS__) \