25 lines · c
1// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s2// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s3// RUN: %clang_cc1 -x c -fsyntax-only -Wbool-operation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s4// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s5// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s6// RUN: %clang_cc1 -x c++ -fsyntax-only -Wbool-operation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s7 8#ifdef __cplusplus9typedef bool boolean;10#else11typedef _Bool boolean;12#endif13 14void 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