1 | // RUN: %check_clang_tidy %s bugprone-too-small-loop-variable %t -- -- --target=x86_64-linux |
2 | |
3 | // MagnitudeBitsUpperLimit = 16 (default value) |
4 | |
5 | unsigned long size() { return 294967296l; } |
6 | |
7 | void voidFilteredOutForLoop1() { |
8 | for (long i = 0; i < size(); ++i) { |
9 | // no warning |
10 | } |
11 | } |
12 | |
13 | void voidCaughtForLoop1() { |
14 | for (int i = 0; i < size(); ++i) { |
15 | // no warning |
16 | } |
17 | } |
18 | |
19 | void voidCaughtForLoop2() { |
20 | for (short i = 0; i < size(); ++i) { |
21 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: loop variable has narrower type 'short' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable] |
22 | } |
23 | } |
24 | |