1 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -verify %s \
2 // RUN: -analyzer-checker=core,deadcode,alpha.security.taint \
5 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -verify %s \
6 // RUN: -analyzer-checker=core,deadcode,alpha.security.taint \
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.
12 #include "Inputs/errno_var.h"
15 #include "Inputs/errno_func.h"
17 #include "Inputs/system-header-simulator.h"
22 // expected-no-diagnostics
24 // Test errno gets invalidated by a system call.
25 int testErrnoSystem(void) {
28 fscanf(stdin
, "%d", &i
);
30 fscanf(stdin
, "%d", &i
); // errno gets invalidated here.
31 return 5 / errno
; // no-warning
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) {
43 fscanf(stdin
, "%d", &i
);
45 foo(); // errno gets invalidated here.
46 return 5 / errno
; // no-warning