1// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-suspicious-semicolon %t
2
3void fail()
4{
5 int x = 0;
6 if(x > 5); (void)x;
7 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
8 // CHECK-FIXES: if(x > 5) (void)x;
9}
10
11template <int X>
12int foo(int a) {
13 if constexpr(X > 0) {
14 return a;
15 }
16 return a + 1;
17}
18
19template <int X>
20int foo2(int a) {
21 // FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
22 // for details.
23 if constexpr(X > 0);
24 return a;
25 return a + 1;
26}
27
28int main(void) {
29 foo2<0>(a: 1);
30 return foo<0>(a: 1);
31}
32

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-semicolon-constexpr.cpp