From 19d9b60787a5b9340b8adf4b3e918c356bb2bd90 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 8 Oct 2012 09:17:20 +0200 Subject: [PATCH] warnings: avoid warnings from clang Fix the following warning parse-gram.c:2078:14: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if (((yyn) == (-91))) ~~~~~~^~~~~~~~ parse-gram.c:2078:14: note: remove extraneous parentheses around the comparison to silence this warning if (((yyn) == (-91))) ~ ^ ~ parse-gram.c:2078:14: note: use '=' to turn this equality comparison into an assignment if (((yyn) == (-91))) ^~ = 1 error generated. and the following one: input.cc:740:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn] static void yyMemoryExhausted (yyGLRStack* yystackp) __attribute__ ((__noreturn__)); static void yyMemoryExhausted (yyGLRStack* yystackp) { YYLONGJMP (yystackp->yyexception_buffer, 2); } ^ 1 warning and 1 error generated. This is Apple clang version 3.1 (tags/Apple/clang-318.0.61). * data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B) to avoid this warning. Any reasonable compiler should generate the same code. * src/uniqstr.h (UNIQSTR_EQ): Likewise. * data/glr.c (LONGJMP): abort after longjmp to pacify clang. --- data/c.m4 | 2 +- data/glr.c | 3 ++- src/uniqstr.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/c.m4 b/data/c.m4 index fd2203eb..994d2964 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -184,7 +184,7 @@ m4_define([b4_table_value_equals], [m4_if(m4_eval($3 < m4_indir([b4_]$1[_min]) || m4_indir([b4_]$1[_max]) < $3), [1], [[YYID (0)]], - [[((]$2[) == (]$3[))]])]) + [(!!(($2) == ($3)))])]) ## ---------## diff --git a/data/glr.c b/data/glr.c index 9b8ff67c..79d6ffd0 100644 --- a/data/glr.c +++ b/data/glr.c @@ -290,7 +290,8 @@ b4_percent_code_get[]dnl # include # define YYJMP_BUF jmp_buf # define YYSETJMP(Env) setjmp (Env) -# define YYLONGJMP(Env, Val) longjmp (Env, Val) +// Pacify clang. +# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0)) #endif /*-----------------. diff --git a/src/uniqstr.h b/src/uniqstr.h index 913da39f..677ecc42 100644 --- a/src/uniqstr.h +++ b/src/uniqstr.h @@ -36,7 +36,7 @@ uniqstr uniqstr_vsprintf (char const *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); /* Two uniqstr values have the same value iff they are the same. */ -#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2)) +#define UNIQSTR_EQ(USTR1, USTR2) (!!((USTR1) == (USTR2))) /* Compare two uniqstr a la strcmp: negative for <, nul for =, and positive for >. Undefined order, relies on addresses. */ -- 2.45.2