let clang use the constant-return error() macro
Commit e208f9c converted error() into a macro to make its constant return value more apparent to calling code. Commit 5ded807 prevents us using this macro with clang, since clang's -Wunused-value is smart enough to realize that the constant "-1" is useless in some contexts. However, since the last commit puts the constant behind an inline function call, this is enough to prevent the -Wunused-value warning on both modern gcc and clang. So we can now re-enable the macro when compiling with clang. Tested with clang 3.3, 3.4, and 3.5. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 6, 2014 at 11:17 UTC
ff0a80af724e81dbad6a269847523e39c2e7e479
3 files changed
+3
-3
cache.h
+1
-1
@@ -1183,7 +1183,7 @@ extern int check_repository_format_version(const char *var, const char *value, v
1183
extern int git_env_bool(const char *, int);
1184
extern int git_config_system(void);
1185
extern int config_error_nonbool(const char *);
1186
-#if defined(__GNUC__) && ! defined(__clang__)
1186
+#if defined(__GNUC__)
1187
#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
1188
#endif
1189
extern const char *get_log_output_encoding(void);
git-compat-util.h
+1
-1
@@ -342,7 +342,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
342
* trying to help gcc, anyway, it's OK; other compilers will fall back to
343
* using the function as usual.
344
*/
345
-#if defined(__GNUC__) && ! defined(__clang__)
345
+#if defined(__GNUC__)
346
static inline int const_error(void)
347
{
348
return -1;
parse-options.h
+1
-1
@@ -179,7 +179,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
179
180
extern int optbug(const struct option *opt, const char *reason);
181
extern int opterror(const struct option *opt, const char *reason, int flags);
182
-#if defined(__GNUC__) && ! defined(__clang__)
182
+#if defined(__GNUC__)
183
#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
184
#endif
185