1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion -std=c++11 %s
9 // Result of ! must be type bool.
13 #if __cplusplus < 201703L
15 extern void f0_1(int*);
17 #if __cplusplus >= 201103L // C++11 or later
18 // expected-warning@-2 {{'register' storage class specifier is deprecated}}
25 template <class T
> void bar(T
&x
) { T::fail(); }
26 template <class T
> void bar(volatile T
&x
) {}
38 bar(x
+= E_zero
); // expected-error {{incompatible type}}
43 return x
&& 4; // expected-warning {{use of logical '&&' with constant operand}} \
44 // expected-note {{use '&' for a bitwise operation}} \
45 // expected-note {{remove constant to silence this warning}}
47 return x
&& sizeof(int) == 4; // no warning, RHS is logical op.
53 return x
&& (unsigned)0; // expected-warning {{use of logical '&&' with constant operand}} \
54 // expected-note {{use '&' for a bitwise operation}} \
55 // expected-note {{remove constant to silence this warning}}
57 return x
|| (unsigned)1; // expected-warning {{use of logical '||' with constant operand}} \
58 // expected-note {{use '|' for a bitwise operation}}
60 return x
|| 0; // expected-warning {{use of logical '||' with constant operand}} \
61 // expected-note {{use '|' for a bitwise operation}}
62 return x
|| 1; // expected-warning {{use of logical '||' with constant operand}} \
63 // expected-note {{use '|' for a bitwise operation}}
64 return x
|| -1; // expected-warning {{use of logical '||' with constant operand}} \
65 // expected-note {{use '|' for a bitwise operation}}
66 return x
|| 5; // expected-warning {{use of logical '||' with constant operand}} \
67 // expected-note {{use '|' for a bitwise operation}}
68 return x
&& 0; // expected-warning {{use of logical '&&' with constant operand}} \
69 // expected-note {{use '&' for a bitwise operation}} \
70 // expected-note {{remove constant to silence this warning}}
71 return x
&& 1; // expected-warning {{use of logical '&&' with constant operand}} \
72 // expected-note {{use '&' for a bitwise operation}} \
73 // expected-note {{remove constant to silence this warning}}
74 return x
&& -1; // expected-warning {{use of logical '&&' with constant operand}} \
75 // expected-note {{use '&' for a bitwise operation}} \
76 // expected-note {{remove constant to silence this warning}}
77 return x
&& 5; // expected-warning {{use of logical '&&' with constant operand}} \
78 // expected-note {{use '&' for a bitwise operation}} \
79 // expected-note {{remove constant to silence this warning}}
80 return x
|| (0); // expected-warning {{use of logical '||' with constant operand}} \
81 // expected-note {{use '|' for a bitwise operation}}
82 return x
|| (1); // expected-warning {{use of logical '||' with constant operand}} \
83 // expected-note {{use '|' for a bitwise operation}}
84 return x
|| (-1); // expected-warning {{use of logical '||' with constant operand}} \
85 // expected-note {{use '|' for a bitwise operation}}
86 return x
|| (5); // expected-warning {{use of logical '||' with constant operand}} \
87 // expected-note {{use '|' for a bitwise operation}}
88 return x
&& (0); // expected-warning {{use of logical '&&' with constant operand}} \
89 // expected-note {{use '&' for a bitwise operation}} \
90 // expected-note {{remove constant to silence this warning}}
91 return x
&& (1); // expected-warning {{use of logical '&&' with constant operand}} \
92 // expected-note {{use '&' for a bitwise operation}} \
93 // expected-note {{remove constant to silence this warning}}
94 return x
&& (-1); // expected-warning {{use of logical '&&' with constant operand}} \
95 // expected-note {{use '&' for a bitwise operation}} \
96 // expected-note {{remove constant to silence this warning}}
97 return x
&& (5); // expected-warning {{use of logical '&&' with constant operand}} \
98 // expected-note {{use '&' for a bitwise operation}} \
99 // expected-note {{remove constant to silence this warning}}
102 template<unsigned int A
, unsigned int B
> struct S
106 e2
= A
&& 7 // expected-warning {{use of logical '&&' with constant operand}} \
107 // expected-note {{use '&' for a bitwise operation}} \
108 // expected-note {{remove constant to silence this warning}}
113 int y
= B
&& 3; // expected-warning {{use of logical '&&' with constant operand}} \
114 // expected-note {{use '&' for a bitwise operation}} \
115 // expected-note {{remove constant to silence this warning}}
141 bool r2
= X
|| Y2
; // expected-warning {{use of logical '||' with constant operand}} \
142 // expected-note {{use '|' for a bitwise operation}}