1 // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s
2 // RUN: %clang_cc1 -x c -fsyntax-only -verify %s
3 // RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
4 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s
5 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
6 // RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
7 
8 #ifdef __cplusplus
9 typedef bool boolean;
10 #else
11 typedef _Bool boolean;
12 #endif
13 
test(boolean b,int i)14 void test(boolean b, int i) {
15   b = ~b; // expected-warning {{bitwise negation of a boolean expression always evaluates to 'true'; did you mean logical negation?}}
16   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
17   b = ~(b); // expected-warning {{bitwise negation of a boolean expression always evaluates to 'true'; did you mean logical negation?}}
18   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
19   b = ~i;
20   i = ~b; // expected-warning {{bitwise negation of a boolean expression; did you mean logical negation?}}
21   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
22   b = ~(i > 4); // expected-warning {{bitwise negation of a boolean expression always evaluates to 'true'; did you mean logical negation?}}
23   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
24 }
25