summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/checkers/cert-limited-randomness.cpp
blob: 845b7350de9f56e497842dcca2ff9d8fd9461383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// RUN: %check_clang_tidy %s cert-msc50-cpp %t

int rand();
int rand(int);

namespace std {
using ::rand;
}

namespace nonstd {
  int rand();
}

void testFunction1() {
  int i = std::rand();
  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp]

  int j = ::rand();
  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp]

  int k = rand(i);

  int l = nonstd::rand();

  int m = rand();
  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness; use C++11 random library instead [cert-msc50-cpp]
}

OpenPOWER on IntegriCloud