Clang Project

clang_source_code/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify -analyzer-output=sarif -o - | %diff_sarif %S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
2#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
30