brintos

brintos / llvm-project-archived public Read only

0
0
Text · 842 B · b83a093 Raw
28 lines · c
1// RUN: %check_clang_tidy -std=c11-or-later %s misc-static-assert %t2// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 03 4void abort(void) {}5#ifdef NDEBUG6#define assert(x) 17#else8#define assert(x)                                                              \9  if (!(x))                                                                    \10  abort()11#endif12 13void f(void) {14  int x = 1;15  assert(x == 0);16  // CHECK-FIXES: assert(x == 0);17 18  #define static_assert(x, msg) _Static_assert(x, msg)19  assert(11 == 5 + 6);20  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be21  // CHECK-FIXES: static_assert(11 == 5 + 6, "");22  #undef static_assert23 24  assert(10 == 5 + 5);25  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be26  // CHECK-FIXES: static_assert(10 == 5 + 5, "");27}28