1 // RUN: %check_clang_tidy %s cert-msc32-c %t -- -config="{CheckOptions: [{key: cert-msc32-c.DisallowedSeedTypes, value: 'some_type,time_t'}]}" -- -std=c99
2 
3 void srand(int seed);
4 typedef int time_t;
5 time_t time(time_t *t);
6 
f()7 void f() {
8   srand(1);
9   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c]
10 
11   const int a = 1;
12   srand(a);
13   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c]
14 
15   time_t t;
16   srand(time(&t)); // Disallowed seed type
17   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc32-c]
18 }
19 
g()20 void g() {
21   typedef int user_t;
22   user_t a = 1;
23   srand(a);
24 
25   int b = 1;
26   srand(b); // Can not evaluate as int
27 }
28