1 // RUN: %clang_cc1 -fsyntax-only -verify %s -DSILENCE
2 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wbitwise-op-parentheses
3 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wparentheses
4 // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -Wbitwise-op-parentheses 2>&1 | FileCheck %s
5 
6 #ifdef SILENCE
7 // expected-no-diagnostics
8 #endif
9 
bitwise_op_parentheses(unsigned i)10 void bitwise_op_parentheses(unsigned i) {
11   (void)(i & i | i);
12 #ifndef SILENCE
13   // expected-warning@-2 {{'&' within '|'}}
14   // expected-note@-3 {{place parentheses around the '&' expression to silence this warning}}
15 #endif
16   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
17   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
18 
19   (void)(i | i & i);
20 #ifndef SILENCE
21   // expected-warning@-2 {{'&' within '|'}}
22   // expected-note@-3 {{place parentheses around the '&' expression to silence this warning}}
23 #endif
24   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
25   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
26 
27   (void)(i ^ i | i);
28 #ifndef SILENCE
29   // expected-warning@-2 {{'^' within '|'}}
30   // expected-note@-3 {{place parentheses around the '^' expression to silence this warning}}
31 #endif
32   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
33   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
34 
35   (void)(i | i ^ i);
36 #ifndef SILENCE
37   // expected-warning@-2 {{'^' within '|'}}
38   // expected-note@-3 {{place parentheses around the '^' expression to silence this warning}}
39 #endif
40   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
41   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
42 
43   (void)(i & i ^ i);
44 #ifndef SILENCE
45   // expected-warning@-2 {{'&' within '^'}}
46   // expected-note@-3 {{place parentheses around the '&' expression to silence this warning}}
47 #endif
48   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
49   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
50 
51   (void)(i ^ i & i);
52 #ifndef SILENCE
53   // expected-warning@-2 {{'&' within '^'}}
54   // expected-note@-3 {{place parentheses around the '&' expression to silence this warning}}
55 #endif
56   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
57   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
58 }
59