121 lines · c
1// TODO: When Clang adds support for decimal floating point types, enable these tests by:2// 1. Removing all the #if 0 + #endif guards.3// 2. Removing all occurrences of the string "DISABLED-" in this file.4// 3. Deleting this message.5 6// RUN: %check_clang_tidy -std=c23-or-later %s readability-uppercase-literal-suffix %t7 8void bit_precise_literal_suffix() {9 // _BitInt()10 11 static constexpr auto v1 = 1wb;12 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wb', which is not uppercase13 // CHECK-FIXES: static constexpr auto v1 = 1WB;14 static_assert(v1 == 1WB);15 16 static constexpr auto v2 = 1WB; // OK.17 static_assert(v2 == 1WB);18 19 // _BitInt() Unsigned20 21 static constexpr auto v3 = 1wbu;22 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbu', which is not uppercase23 // CHECK-FIXES: static constexpr auto v3 = 1WBU;24 static_assert(v3 == 1WBU);25 26 static constexpr auto v4 = 1WBu;27 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'WBu', which is not uppercase28 // CHECK-FIXES: static constexpr auto v4 = 1WBU;29 static_assert(v4 == 1WBU);30 31 static constexpr auto v5 = 1wbU;32 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'wbU', which is not uppercase33 // CHECK-FIXES: static constexpr auto v5 = 1WBU;34 static_assert(v5 == 1WBU);35 36 static constexpr auto v6 = 1WBU; // OK.37 static_assert(v6 == 1WBU);38 39 // Unsigned _BitInt()40 41 static constexpr auto v7 = 1uwb;42 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uwb', which is not uppercase43 // CHECK-FIXES: static constexpr auto v7 = 1UWB;44 static_assert(v7 == 1UWB);45 46 static constexpr auto v8 = 1uWB;47 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'uWB', which is not uppercase48 // CHECK-FIXES: static constexpr auto v8 = 1UWB;49 static_assert(v8 == 1UWB);50 51 static constexpr auto v9 = 1Uwb;52 // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'Uwb', which is not uppercase53 // CHECK-FIXES: static constexpr auto v9 = 1UWB;54 static_assert(v9 == 1UWB);55 56 static constexpr auto v10 = 1UWB; // OK.57 static_assert(v10 == 1UWB);58}59 60void decimal_floating_point_suffix() {61 // _Decimal3262 63#if 064 static constexpr auto v1 = 1.df;65 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase66 // DISABLED-CHECK-FIXES: static constexpr auto v1 = 1.DF;67 static_assert(v1 == 1.DF);68 69 static constexpr auto v2 = 1.e0df;70 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'df', which is not uppercase71 // DISABLED-CHECK-FIXES: static constexpr auto v2 = 1.e0DF;72 static_assert(v2 == 1.DF);73 74 static constexpr auto v3 = 1.DF; // OK.75 static_assert(v3 == 1.DF);76 77 static constexpr auto v4 = 1.e0DF; // OK.78 static_assert(v4 == 1.DF);79#endif80 81 // _Decimal6482 83#if 084 static constexpr auto v5 = 1.dd;85 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase86 // DISABLED-CHECK-FIXES: static constexpr auto v5 = 1.DD;87 static_assert(v5 == 1.DD);88 89 static constexpr auto v6 = 1.e0dd;90 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dd', which is not uppercase91 // DISABLED-CHECK-FIXES: static constexpr auto v6 = 1.e0DD;92 static_assert(v6 == 1.DD);93 94 static constexpr auto v7 = 1.DD; // OK.95 static_assert(v7 == 1.DD);96 97 static constexpr auto v8 = 1.e0DD; // OK.98 static_assert(v8 == 1.DD);99#endif100 101 // _Decimal128102 103#if 0104 static constexpr auto v9 = 1.dl;105 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:30: warning: floating point literal has suffix 'dl', which is not uppercase106 // DISABLED-CHECK-FIXES: static constexpr auto v9 = 1.DL;107 static_assert(v9 == 1.DL);108 109 static constexpr auto v10 = 1.e0dl;110 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has suffix 'dl', which is not uppercase111 // DISABLED-CHECK-FIXES: static constexpr auto v10 = 1.e0DL;112 static_assert(v10 == 1.DL);113 114 static constexpr auto v11 = 1.DL; // OK.115 static_assert(v11 == 1.DL);116 117 static constexpr auto v12 = 1.e0DL; // OK.118 static_assert(v12 == 1.DL);119#endif120}121