summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/if-empty-body.cpp
blob: ec7f89d68e720b1180e2dcc95c6b5b9cce39997c (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
32
33
34
35
// RUN: %clang_cc1 -fsyntax-only -verify %s

void f1(int a) {
    if (a); // expected-warning {{if statement has empty body}}
}

void f2(int a) {
    if (a) {}
}

void f3() {
  if (1)
    xx;      // expected-error {{use of undeclared identifier}}
  return;    // no empty body warning.
}

// Don't warn about an empty body if is expanded from a macro.
void f4(int i) {
  #define BODY(x)
  if (i == i) // expected-warning{{self-comparison always evaluates to true}}
    BODY(0);
  #undef BODY
}

template <typename T>
void tf() {
  #define BODY(x)
  if (0)
    BODY(0);
  #undef BODY
}

void f5() {
    tf<int>();
}
OpenPOWER on IntegriCloud