[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / global-region-invalidation-errno.c
blob9de10ad59095a2719c735d147e3756bed6140d5a
1 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -verify %s \
2 // RUN: -analyzer-checker=core,deadcode,alpha.security.taint \
3 // RUN: -DERRNO_VAR
5 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -verify %s \
6 // RUN: -analyzer-checker=core,deadcode,alpha.security.taint \
7 // RUN: -DERRNO_FUNC
9 // Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
10 // The errno value can be defined in multiple ways, test with each one.
11 #ifdef ERRNO_VAR
12 #include "Inputs/errno_var.h"
13 #endif
14 #ifdef ERRNO_FUNC
15 #include "Inputs/errno_func.h"
16 #endif
17 #include "Inputs/system-header-simulator.h"
20 void foo(void);
22 // expected-no-diagnostics
24 // Test errno gets invalidated by a system call.
25 int testErrnoSystem(void) {
26 int i;
27 int *p = 0;
28 fscanf(stdin, "%d", &i);
29 if (errno == 0) {
30 fscanf(stdin, "%d", &i); // errno gets invalidated here.
31 return 5 / errno; // no-warning
34 errno = 0;
35 fscanf(stdin, "%d", &i); // errno gets invalidated here.
36 return 5 / errno; // no-warning
39 // Test that errno gets invalidated by internal calls.
40 int testErrnoInternal(void) {
41 int i;
42 int *p = 0;
43 fscanf(stdin, "%d", &i);
44 if (errno == 0) {
45 foo(); // errno gets invalidated here.
46 return 5 / errno; // no-warning
48 return 0;