| 1 | // RUN: %check_clang_tidy -check-suffix=DEFAULT %s \ |
| 2 | // RUN: bugprone-narrowing-conversions %t -- \ |
| 3 | // RUN: -config='{CheckOptions: {bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: true}}' |
| 4 | |
| 5 | // RUN: %check_clang_tidy -check-suffix=DISABLED %s \ |
| 6 | // RUN: bugprone-narrowing-conversions %t -- \ |
| 7 | // RUN: -config='{CheckOptions: {bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: false}}' |
| 8 | |
| 9 | void foo(unsigned long long value) { |
| 10 | double a = value; |
| 11 | // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:14: warning: narrowing conversion from 'unsigned long long' to 'double' [bugprone-narrowing-conversions] |
| 12 | // DISABLED: No warning for integer to floating-point narrowing conversions when WarnOnIntegerToFloatingPointNarrowingConversion = false. |
| 13 | } |
| 14 | |
| 15 | void floating_point_to_integer_is_still_not_ok(double f) { |
| 16 | int a = f; |
| 17 | // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:11: warning: narrowing conversion from 'double' to 'int' [bugprone-narrowing-conversions] |
| 18 | // CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:11: warning: narrowing conversion from 'double' to 'int' [bugprone-narrowing-conversions] |
| 19 | } |
| 20 | |