[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / errno.c
blob3bfe19a287d1bf9f8cc392f97baf90420886af07
1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=apiModeling.Errno \
4 // RUN: -analyzer-checker=debug.ExprInspection \
5 // RUN: -analyzer-checker=debug.ErrnoTest \
6 // RUN: -DERRNO_VAR
8 // RUN: %clang_analyze_cc1 -verify %s \
9 // RUN: -analyzer-checker=core \
10 // RUN: -analyzer-checker=apiModeling.Errno \
11 // RUN: -analyzer-checker=debug.ExprInspection \
12 // RUN: -analyzer-checker=debug.ErrnoTest \
13 // RUN: -DERRNO_FUNC
15 #ifdef ERRNO_VAR
16 #include "Inputs/errno_var.h"
17 #endif
18 #ifdef ERRNO_FUNC
19 #include "Inputs/errno_func.h"
20 #endif
22 void clang_analyzer_eval(int);
23 void ErrnoTesterChecker_setErrno(int);
24 int ErrnoTesterChecker_getErrno();
25 int ErrnoTesterChecker_setErrnoIfError();
26 int ErrnoTesterChecker_setErrnoIfErrorRange();
28 void something();
30 void test() {
31 // Test if errno is initialized.
32 clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
34 ErrnoTesterChecker_setErrno(1);
35 // Test if errno was recognized and changed.
36 clang_analyzer_eval(errno == 1); // expected-warning{{TRUE}}
37 clang_analyzer_eval(ErrnoTesterChecker_getErrno() == 1); // expected-warning{{TRUE}}
39 something();
41 // Test if errno was invalidated.
42 clang_analyzer_eval(errno); // expected-warning{{UNKNOWN}}
43 clang_analyzer_eval(ErrnoTesterChecker_getErrno()); // expected-warning{{UNKNOWN}}
46 void testRange(int X) {
47 if (X > 0) {
48 ErrnoTesterChecker_setErrno(X);
49 clang_analyzer_eval(errno > 0); // expected-warning{{TRUE}}
53 void testIfError() {
54 if (ErrnoTesterChecker_setErrnoIfError())
55 clang_analyzer_eval(errno == 11); // expected-warning{{TRUE}}
58 void testIfErrorRange() {
59 if (ErrnoTesterChecker_setErrnoIfErrorRange()) {
60 clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
61 clang_analyzer_eval(errno == 1); // expected-warning{{FALSE}} expected-warning{{TRUE}}