summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
blob: 6532940eaf2314b2e2621246e2bbe57bc8c88a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++17

// Constexpr if is an exception to the rule, we cannot remove the else.
void f() {
  if (sizeof(int) > 4)
    return;
  else
    return;
  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: do not use 'else' after 'return'

  if constexpr (sizeof(int) > 4)
    return;
  else
    return;

  if constexpr (sizeof(int) > 4)
    return;
  else if constexpr (sizeof(long) > 4)
    return;
  else
    return;
}
OpenPOWER on IntegriCloud