1 // RUN: %check_clang_tidy %s misc-static-assert %t -- -- -std=c11
2 // RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
3
abort()4 void abort() {}
5 #ifdef NDEBUG
6 #define assert(x) 1
7 #else
8 #define assert(x) \
9 if (!(x)) \
10 abort()
11 #endif
12
f(void)13 void 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 be
21 // CHECK-FIXES: {{^ }}static_assert(11 == 5 + 6, "");
22 #undef static_assert
23
24 assert(10 == 5 + 5);
25 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
26 // CHECK-FIXES: {{^ }}static_assert(10 == 5 + 5, "");
27 }
28