1 // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wint-in-bool-context %s
2 // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
3 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wint-in-bool-context %s
4 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
9 #define SHIFT(l, r) l << r
16 typedef _Bool boolean
;
25 int test(int a
, unsigned b
, enum num n
) {
27 r
= a
<< a
; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(a << a) != 0'?}}
28 r
= MM
; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(a << a) != 0'?}}
29 r
= (1 << 7); // expected-warning {{converting the result of '<<' to a boolean always evaluates to true}}
30 r
= 2UL << 2; // expected-warning {{converting the result of '<<' to a boolean always evaluates to true}}
31 r
= 0 << a
; // expected-warning {{converting the result of '<<' to a boolean always evaluates to false}}
32 r
= 0 << 2; // expected-warning {{converting the result of '<<' to a boolean always evaluates to false}}
33 r
= 1 << 0; // expected-warning {{converting the result of '<<' to a boolean always evaluates to true}}
34 r
= 1 << 2; // expected-warning {{converting the result of '<<' to a boolean always evaluates to true}}
35 r
= 1ULL << 2; // expected-warning {{converting the result of '<<' to a boolean always evaluates to true}}
36 r
= 2 << b
; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(2 << b) != 0'?}}
37 r
= (unsigned)(2 << b
);
39 r
= (1 << a
); // expected-warning {{converting the result of '<<' to a boolean; did you mean '(1 << a) != 0'?}}
40 r
= TWO
<< a
; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(2 << a) != 0'?}}
41 r
= a
<< 7; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(a << 7) != 0'?}}
42 r
= ONE
<< a
; // expected-warning {{converting the result of '<<' to a boolean; did you mean '(1 << a) != 0'?}}
43 if (TWO
<< a
) // expected-warning {{converting the result of '<<' to a boolean; did you mean '(2 << a) != 0'?}}
46 for (a
= 0; 1 << a
; a
++) // expected-warning {{converting the result of '<<' to a boolean; did you mean '(1 << a) != 0'?}}
49 if (a
<< TWO
) // expected-warning {{converting the result of '<<' to a boolean; did you mean '(a << 2) != 0'?}}
53 // expected-warning@-1 {{converting the enum constant to a boolean}}
57 // expected-warning@-1 {{converting the enum constant to a boolean}}
61 // expected-warning@-1 {{converting the enum constant to a boolean}}
65 // expected-warning@-1 {{converting the enum constant to a boolean}}
69 // expected-warning@-1 {{converting the enum constant to a boolean}}
72 // Don't warn in macros.