+2023-06-02 Bruno Haible <bruno@clisp.org>
+
+ error: Avoid implicit-fallthrough warnings with -O0 (regr. 2023-05-30).
+ * lib/error.in.h (__gl_error_call): Parenthesize status. When not
+ optimizing, expand to code without compound statements.
+
2023-06-01 Bruno Haible <bruno@clisp.org>
getprogname: Add support for ASCII-compatible environments in z/OS.
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM
#endif
+/* Helper macro for supporting the compiler's control flow analysis better.
+ Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */
#ifdef __GNUC__
-# define __gl_error_call(function, status, ...) \
- ({ \
- int const __errstatus = status; \
- (function) (__errstatus, __VA_ARGS__); \
- __errstatus != 0 ? unreachable () : (void) 0; \
- })
+/* Avoid evaluating STATUS twice, if this is possible without making the
+ "warning: this statement may fall through" reappear. */
+# if __OPTIMIZE__
+# define __gl_error_call(function, status, ...) \
+ ({ \
+ int const __errstatus = (status); \
+ (function) (__errstatus, __VA_ARGS__); \
+ __errstatus != 0 ? unreachable () : (void) 0; \
+ })
+# else
+# define __gl_error_call(function, status, ...) \
+ ((function) (status, __VA_ARGS__), \
+ (status) != 0 ? unreachable () : (void)0 \
+ )
+# endif
#else
# define __gl_error_call(function, status, ...) \
(function) (status, __VA_ARGS__)