1 // RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -target aarch64-linux-gnu -I %S
2
3 #include "readability-uppercase-literal-suffix.h"
4
float16_normal_literals()5 void float16_normal_literals() {
6 // _Float16
7
8 static constexpr auto v14 = 1.f16;
9 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase
10 // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.f16;
11 // CHECK-MESSAGES-NEXT: ^ ~
12 // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
13 // CHECK-FIXES: static constexpr auto v14 = 1.F16;
14 static_assert(is_same<decltype(v14), const _Float16>::value, "");
15 static_assert(v14 == 1.F16, "");
16
17 static constexpr auto v15 = 1.e0f16;
18 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase
19 // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0f16;
20 // CHECK-MESSAGES-NEXT: ^ ~
21 // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
22 // CHECK-FIXES: static constexpr auto v15 = 1.e0F16;
23 static_assert(is_same<decltype(v15), const _Float16>::value, "");
24 static_assert(v15 == 1.F16, "");
25
26 static constexpr auto v16 = 1.F16; // OK.
27 static_assert(is_same<decltype(v16), const _Float16>::value, "");
28 static_assert(v16 == 1.F16, "");
29
30 static constexpr auto v17 = 1.e0F16; // OK.
31 static_assert(is_same<decltype(v17), const _Float16>::value, "");
32 static_assert(v17 == 1.F16, "");
33 }
34
float16_hexadecimal_literals()35 void float16_hexadecimal_literals() {
36 // _Float16
37
38 static constexpr auto v13 = 0xfp0f16;
39 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'f16', which is not uppercase
40 // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 0xfp0f16;
41 // CHECK-MESSAGES-NEXT: ^ ~
42 // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
43 // CHECK-FIXES: static constexpr auto v13 = 0xfp0F16;
44 static_assert(is_same<decltype(v13), const _Float16>::value, "");
45 static_assert(v13 == 0xfp0F16, "");
46
47 static constexpr auto v14 = 0xfp0F16; // OK.
48 static_assert(is_same<decltype(v14), const _Float16>::value, "");
49 static_assert(v14 == 0xfp0F16, "");
50
51 }
52