From 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 13:06:31 +0000 Subject: Vendor import of clang trunk r126079: http://llvm.org/svn/llvm-project/cfe/trunk@126079 --- test/SemaCXX/if-empty-body.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/SemaCXX/if-empty-body.cpp (limited to 'test/SemaCXX/if-empty-body.cpp') diff --git a/test/SemaCXX/if-empty-body.cpp b/test/SemaCXX/if-empty-body.cpp new file mode 100644 index 0000000..ec7f89d --- /dev/null +++ b/test/SemaCXX/if-empty-body.cpp @@ -0,0 +1,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 +void tf() { + #define BODY(x) + if (0) + BODY(0); + #undef BODY +} + +void f5() { + tf(); +} -- cgit v1.1