summaryrefslogtreecommitdiffstats
path: root/test/clang-tidy/bugprone-too-small-loop-variable-magniute-bits-upper-limit.cpp
blob: d602a1d08e2c6c3f59674e88a7ce616c7596552d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %check_clang_tidy %s bugprone-too-small-loop-variable %t -- -- --target=x86_64-linux

// MagnitudeBitsUpperLimit = 16 (default value)

unsigned long size() { return 294967296l; }

void voidFilteredOutForLoop1() {
  for (long i = 0; i < size(); ++i) {
    // no warning
  }
}

void voidCaughtForLoop1() {
  for (int i = 0; i < size(); ++i) {
    // no warning
  }
}

void voidCaughtForLoop2() {
  for (short i = 0; i < size(); ++i) {
    // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: loop variable has narrower type 'short' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
  }
}