brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 6d6d83d Raw
140 lines · cpp
1// RUN: %check_clang_tidy %s cert-dcl16-c %t -- -- -I %clang_tidy_headers2 3#include "integral_constant.h"4 5void integer_suffix() {6  static constexpr auto v0 = __LINE__; // synthetic7  static constexpr auto v1 = __cplusplus; // synthetic, long8 9  static constexpr auto v2 = 1; // no literal10  static_assert(is_same<decltype(v2), const int>::value, "");11  static_assert(v2 == 1, "");12 13  // Unsigned14 15  static constexpr auto v3 = 1u;16  static_assert(is_same<decltype(v3), const unsigned int>::value, "");17  static_assert(v3 == 1, "");18 19  static constexpr auto v4 = 1U; // OK.20  static_assert(is_same<decltype(v4), const unsigned int>::value, "");21  static_assert(v4 == 1, "");22 23  // Long24 25  static constexpr auto v5 = 1l;26  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not uppercase27  // CHECK-FIXES: static constexpr auto v5 = 1L;28  static_assert(is_same<decltype(v5), const long>::value, "");29  static_assert(v5 == 1, "");30 31  static constexpr auto v6 = 1L; // OK.32  static_assert(is_same<decltype(v6), const long>::value, "");33  static_assert(v6 == 1, "");34 35  // Long Long36 37  static constexpr auto v7 = 1ll;38  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not uppercase39  // CHECK-FIXES: static constexpr auto v7 = 1LL;40  static_assert(is_same<decltype(v7), const long long>::value, "");41  static_assert(v7 == 1, "");42 43  static constexpr auto v8 = 1LL; // OK.44  static_assert(is_same<decltype(v8), const long long>::value, "");45  static_assert(v8 == 1, "");46 47  // Unsigned Long48 49  static constexpr auto v9 = 1ul;50  static_assert(is_same<decltype(v9), const unsigned long>::value, "");51  static_assert(v9 == 1, "");52 53  static constexpr auto v10 = 1uL;54  static_assert(is_same<decltype(v10), const unsigned long>::value, "");55  static_assert(v10 == 1, "");56 57  static constexpr auto v11 = 1Ul;58  static_assert(is_same<decltype(v11), const unsigned long>::value, "");59  static_assert(v11 == 1, "");60 61  static constexpr auto v12 = 1UL; // OK.62  static_assert(is_same<decltype(v12), const unsigned long>::value, "");63  static_assert(v12 == 1, "");64 65  // Long Unsigned66 67  static constexpr auto v13 = 1lu;68  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lu', which is not uppercase69  // CHECK-FIXES: static constexpr auto v13 = 1LU;70  static_assert(is_same<decltype(v13), const unsigned long>::value, "");71  static_assert(v13 == 1, "");72 73  static constexpr auto v14 = 1Lu;74  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'Lu', which is not uppercase75  // CHECK-FIXES: static constexpr auto v14 = 1LU;76  static_assert(is_same<decltype(v14), const unsigned long>::value, "");77  static_assert(v14 == 1, "");78 79  static constexpr auto v15 = 1lU;80  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'lU', which is not uppercase81  // CHECK-FIXES: static constexpr auto v15 = 1LU;82  static_assert(is_same<decltype(v15), const unsigned long>::value, "");83  static_assert(v15 == 1, "");84 85  static constexpr auto v16 = 1LU; // OK.86  static_assert(is_same<decltype(v16), const unsigned long>::value, "");87  static_assert(v16 == 1, "");88 89  // Unsigned Long Long90 91  static constexpr auto v17 = 1ull;92  static_assert(is_same<decltype(v17), const unsigned long long>::value, "");93  static_assert(v17 == 1, "");94 95  static constexpr auto v18 = 1uLL;96  static_assert(is_same<decltype(v18), const unsigned long long>::value, "");97  static_assert(v18 == 1, "");98 99  static constexpr auto v19 = 1Ull;100  static_assert(is_same<decltype(v19), const unsigned long long>::value, "");101  static_assert(v19 == 1, "");102 103  static constexpr auto v20 = 1ULL; // OK.104  static_assert(is_same<decltype(v20), const unsigned long long>::value, "");105  static_assert(v20 == 1, "");106 107  // Long Long Unsigned108 109  static constexpr auto v21 = 1llu;110  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llu', which is not uppercase111  // CHECK-FIXES: static constexpr auto v21 = 1LLU;112  static_assert(is_same<decltype(v21), const unsigned long long>::value, "");113  static_assert(v21 == 1, "");114 115  static constexpr auto v22 = 1LLu;116  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'LLu', which is not uppercase117  // CHECK-FIXES: static constexpr auto v22 = 1LLU;118  static_assert(is_same<decltype(v22), const unsigned long long>::value, "");119  static_assert(v22 == 1, "");120 121  static constexpr auto v23 = 1llU;122  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: integer literal has suffix 'llU', which is not uppercase123  // CHECK-FIXES: static constexpr auto v23 = 1LLU;124  static_assert(is_same<decltype(v23), const unsigned long long>::value, "");125  static_assert(v23 == 1, "");126 127  static constexpr auto v24 = 1LLU; // OK.128  static_assert(is_same<decltype(v24), const unsigned long long>::value, "");129  static_assert(v24 == 1, "");130}131 132void no_warning_on_hex_literals() {133  int a = 0xa;134  int b = 0xb;135  int c = 0xc;136  int d = 0xd;137  int e = 0xe;138  int f = 0xf;139}140