[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / tautological-unsigned-char-zero-compare.cc
blob4d14954b32133bc9ce7298eed90ce4ce4356e138
1 // RUN: %clang_cc1 -fsyntax-only \
2 // RUN: -fno-signed-char \
3 // RUN: -Wtautological-unsigned-zero-compare \
4 // RUN: -Wtautological-unsigned-char-zero-compare \
5 // RUN: -verify=unsigned %s
6 // RUN: %clang_cc1 -fsyntax-only \
7 // RUN: -Wtautological-unsigned-zero-compare \
8 // RUN: -Wtautological-unsigned-char-zero-compare \
9 // RUN: -verify=signed %s
11 void f(char c, unsigned char uc, signed char cc) {
12 if (c < 0)
13 return;
14 // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
15 if (uc < 0)
16 return;
17 // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
18 // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
19 if (cc < 0)
20 return;
21 // Promoted to integer expressions should not warn.
22 if (c - 4 < 0)
23 return;
26 void ref(char &c, unsigned char &uc, signed char &cc) {
27 if (c < 0)
28 return;
29 // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
30 if (uc < 0)
31 return;
32 // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
33 // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
34 if (cc < 0)
35 return;
36 // Promoted to integer expressions should not warn.
37 if (c - 4 < 0)
38 return;