Clang Project

clang_source_code/test/Analysis/security-syntax-checks-no-emit.c
1// RUN: %clang_analyze_cc1 -triple i686-pc-linux-gnu -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
2// expected-no-diagnostics
3
4// This file complements 'security-syntax-checks.m', but tests that we omit
5// specific checks on platforms where they don't make sense.
6
7// Omit the 'rand' check since 'arc4random' is not available on Linux.
8int      rand(void);
9double   drand48(void);
10double   erand48(unsigned short[3]);
11long     jrand48(unsigned short[3]);
12void     lcong48(unsigned short[7]);
13long     lrand48(void);
14long     mrand48(void);
15long     nrand48(unsigned short[3]);
16long     random(void);
17int      rand_r(unsigned *);
18
19void test_rand()
20{
21  unsigned short a[7];
22  unsigned b;
23  
24  rand(); // no-warning
25  drand48(); // no-warning
26  erand48(a); // no-warning
27  jrand48(a); // no-warning
28  lcong48(a); // no-warning
29  lrand48(); // no-warning
30  mrand48(); // no-warning
31  nrand48(a); // no-warning
32  rand_r(&b); // no-warning
33  random(); // no-warning
34}
35