1 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only \
2 // RUN: -Wtautological-unsigned-enum-zero-compare \
3 // RUN: -verify=unsigned,unsigned-signed %s
4 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only \
5 // RUN: -Wtautological-unsigned-enum-zero-compare \
6 // RUN: -verify=unsigned-signed %s
7 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only \
8 // RUN: -verify=silence %s
10 // Okay, this is where it gets complicated.
11 // Then default enum sigdness is target-specific.
12 // On windows, it is signed by default. We do not want to warn in that case.
20 // silence-no-diagnostics
22 if (a
< 0) // unsigned-warning {{comparison of unsigned enum expression < 0 is always false}}
28 if (0 <= a
) // unsigned-warning {{comparison of 0 <= unsigned enum expression is always true}}
32 if (0 > a
) // unsigned-warning {{comparison of 0 > unsigned enum expression is always false}}
34 if (a
>= 0) // unsigned-warning {{comparison of unsigned enum expression >= 0 is always true}}
39 if (a
< 0U) // unsigned-signed-warning {{comparison of unsigned enum expression < 0 is always false}}
45 if (0U <= a
) // unsigned-signed-warning {{comparison of 0 <= unsigned enum expression is always true}}
49 if (0U > a
) // unsigned-signed-warning {{comparison of 0 > unsigned enum expression is always false}}
51 if (a
>= 0U) // unsigned-signed-warning {{comparison of unsigned enum expression >= 0 is always true}}
73 if (b
< 0U) // unsigned-signed-warning {{comparison of unsigned enum expression < 0 is always false}}
79 if (0U <= b
) // unsigned-signed-warning {{comparison of 0 <= unsigned enum expression is always true}}
83 if (0U > b
) // unsigned-signed-warning {{comparison of 0 > unsigned enum expression is always false}}
85 if (b
>= 0U) // unsigned-signed-warning {{comparison of unsigned enum expression >= 0 is always true}}