On 1/24/24 00:57, Jasmine Tang wrote:
Change the style from & to && to reflect boolean result with boolean
operation (instead of bitwise operation)
David Binderman 2017-07-01 13:24:44 UTC
trunk/gcc/cp/lex.c:116]: (style) Boolean result is used in bitwise operation.
Clarify expression with parentheses.
Source code is
gcc_checking_assert (!IDENTIFIER_KIND_BIT_2 (id)
& !IDENTIFIER_KIND_BIT_1 (id)
& !IDENTIFIER_KIND_BIT_0 (id));
Maybe better code
gcc_checking_assert (!IDENTIFIER_KIND_BIT_2 (id)
&& !IDENTIFIER_KIND_BIT_1 (id)
&& !IDENTIFIER_KIND_BIT_0 (id));
Since the _BIT_n macros all produce either 0 or 1, bitwise & has the
same meaning as &&, except possibly faster because it doesn't involve
the shortcut semantics of &&.
I notice the warning suggests "Clarify expression with parentheses." I
suspect that means along the lines of IDENTIFIER_KEYWORD_P and such in
cp-tree.h, where the ! expression is parenthesized:
#define IDENTIFIER_KEYWORD_P(NODE) \
((!IDENTIFIER_KIND_BIT_2 (NODE)) \
& (!IDENTIFIER_KIND_BIT_1 (NODE)) \
& IDENTIFIER_KIND_BIT_0 (NODE))
Does doing that quiet the warning?
Jason