1 | // RUN: %check_clang_tidy -check-suffix=DEFAULT %s \ |
2 | // RUN: cppcoreguidelines-narrowing-conversions %t -- \ |
3 | // RUN: -config='{CheckOptions: {cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: true}}' |
4 | |
5 | // RUN: %check_clang_tidy -check-suffix=DISABLED %s \ |
6 | // RUN: cppcoreguidelines-narrowing-conversions %t -- \ |
7 | // RUN: -config='{CheckOptions: {cppcoreguidelines-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' [cppcoreguidelines-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' [cppcoreguidelines-narrowing-conversions] |
18 | // CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:11: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions] |
19 | } |
20 | |