blob: 3402714a30ae736193d760c4550795273efc8ba2 [file] [log] [blame]
Hubert Tong64b60df2019-06-19 15:27:35 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify -analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b %S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
Aaron Ballman2c0febe2018-11-01 18:57:38 +00002#include "../Inputs/system-header-simulator.h"
3
4int atoi(const char *nptr);
5
6void f(void) {
7 char s[80];
8 scanf("%s", s);
9 int d = atoi(s); // expected-warning {{tainted}}
10}
11
12void g(void) {
13 void (*fp)(int);
14 fp(12); // expected-warning {{Called function pointer is an uninitialized pointer value}}
15}
16
17int h(int i) {
18 if (i == 0)
19 return 1 / i; // expected-warning {{Division by zero}}
20 return 0;
21}
22
23int main(void) {
24 f();
25 g();
26 h(0);
27 return 0;
28}
29