[clang] fix unnecessary warning when using bitand with boolean operators (PR #81976)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 15 09:05:30 PDT 2024
================
@@ -45,8 +45,8 @@ void test(boolean a, boolean b, int *p, volatile int *q, int i) {
b = bar() & (i > 4);
b = (i == 7) & foo();
#ifdef __cplusplus
- b = foo() bitand bar(); // expected-warning {{use of bitwise '&' with boolean operands}}
- // expected-note at -1 {{cast one or both operands to int to silence this warning}}
+ b = foo() bitand bar(); // Ok, no warning expected
+
----------------
AaronBallman wrote:
You should also add test coverage for C with a macro definition for `bitand` and `bitor`, and it'd be good to add a test (both C and C++) that does something like:
```
#define my_fancy_bit_and &
b = foo() my_fancy_bit_and bar();
```
to show this intentionally works with user-defined macros as well.
https://github.com/llvm/llvm-project/pull/81976
More information about the cfe-commits
mailing list