1 // RUN: %check_clang_tidy %s bugprone-narrowing-conversions %t \ 2 // RUN: -config="{CheckOptions: { \ 3 // RUN: bugprone-narrowing-conversions.PedanticMode: true}}" \ 4 // RUN: -- -target x86_64-unknown-linux -fsigned-char 5 6 namespace floats { 7 8 void triggers_wrong_constant_type_warning(double d) { 9 int i = 0.0; 10 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: constant value should be of type of type 'int' instead of 'double' [bugprone-narrowing-conversions] 11 i += 2.0; 12 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constant value should be of type of type 'int' instead of 'double' [bugprone-narrowing-conversions] 13 i += 2.0f; 14 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constant value should be of type of type 'int' instead of 'float' [bugprone-narrowing-conversions] 15 } 16 17 void triggers_narrowing_warning_when_overflowing() { 18 unsigned short us = 65537.0; 19 // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: narrowing conversion from constant 'double' to 'unsigned short' [bugprone-narrowing-conversions] 20 } 21 22 } // namespace floats 23