brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · d2e2ead Raw
23 lines · cpp
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-char5 6namespace floats {7 8void 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 17void 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 floats23