summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
blob: c18dd7bd1e932d275e7fb80f2f782eea7cc6d10e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17

void fail()
{
  int x = 0;
  if(x > 5); (void)x;
  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
  // CHECK-FIXES: if(x > 5) (void)x;
}

template <int X>
int foo(int a) {
    if constexpr(X > 0) {
        return a;
    }
    return a + 1;
}

template <int X>
int foo2(int a) {
    // FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
    // for details.
    if constexpr(X > 0);
        return a;
    return a + 1;
}

int main(void) {
    foo2<0>(1);
    return foo<0>(1);
}
OpenPOWER on IntegriCloud