2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2007-10-11 04:50:11 +08:00
|
|
|
|
|
|
|
void f1(int a) {
|
|
|
|
if (a); // expected-warning {{if statement has empty body}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void f2(int a) {
|
|
|
|
if (a) {}
|
|
|
|
}
|
2007-10-29 13:08:52 +08:00
|
|
|
|
|
|
|
void f3() {
|
|
|
|
if (1)
|
|
|
|
xx; // expected-error {{use of undeclared identifier}}
|
|
|
|
return; // no empty body warning.
|
|
|
|
}
|
|
|
|
|
2010-09-16 08:37:05 +08:00
|
|
|
// Don't warn about an empty body if is expanded from a macro.
|
|
|
|
void f4(int i) {
|
|
|
|
#define BODY ;
|
|
|
|
if (i == i) // expected-warning{{self-comparison always evaluates to true}}
|
|
|
|
BODY
|
|
|
|
#undef BODY
|
|
|
|
}
|
|
|
|
|