Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / errno-options.c
blob0449f22b8f7b4ea39936d79214a7c6b744db82a6
1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=apiModeling.Errno \
4 // RUN: -analyzer-checker=debug.ErrnoTest \
5 // RUN: -analyzer-checker=alpha.unix.Errno \
6 // RUN: -analyzer-config alpha.unix.Errno:AllowErrnoReadOutsideConditionExpressions=false \
7 // RUN: -DERRNO_VAR
9 // RUN: %clang_analyze_cc1 -verify %s \
10 // RUN: -analyzer-checker=core \
11 // RUN: -analyzer-checker=apiModeling.Errno \
12 // RUN: -analyzer-checker=debug.ErrnoTest \
13 // RUN: -analyzer-checker=alpha.unix.Errno \
14 // RUN: -analyzer-config alpha.unix.Errno:AllowErrnoReadOutsideConditionExpressions=false \
15 // RUN: -DERRNO_FUNC
17 #include "Inputs/system-header-simulator.h"
18 #ifdef ERRNO_VAR
19 #include "Inputs/errno_var.h"
20 #endif
21 #ifdef ERRNO_FUNC
22 #include "Inputs/errno_func.h"
23 #endif
25 int ErrnoTesterChecker_setErrnoIfError();
27 void test_cond() {
28 ErrnoTesterChecker_setErrnoIfError();
29 int A = errno ? 1 : 2;
30 // expected-warning@-1{{An undefined value may be read from 'errno'}}
33 void test_errno_store_into_variable() {
34 ErrnoTesterChecker_setErrnoIfError();
35 int a = errno;
36 // expected-warning@-1{{An undefined value may be read from 'errno'}}
39 void test_errno_store_into_variable_in_expr() {
40 ErrnoTesterChecker_setErrnoIfError();
41 int a = 4 + errno;
42 // expected-warning@-1{{An undefined value may be read from 'errno'}}
45 int test_errno_return() {
46 ErrnoTesterChecker_setErrnoIfError();
47 return errno;
48 // expected-warning@-1{{An undefined value may be read from 'errno'}}
51 int test_errno_return_expr() {
52 ErrnoTesterChecker_setErrnoIfError();
53 return errno > 10;
54 // expected-warning@-1{{An undefined value may be read from 'errno'}}