diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2015-03-15 01:08:23 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2015-03-15 01:08:23 +0000 |
commit | ad80af8f191503fe33deecf8efc57ff2878aa3d1 (patch) | |
tree | 6c2f4a03c9f707b602fb36fd801d22c1e817dcb7 /clang/test/SemaCXX/warn-empty-body.cpp | |
parent | 86ecb1bdaf2e7570ac33cc9e00d76375cf00d5d2 (diff) | |
download | bcm5719-llvm-ad80af8f191503fe33deecf8efc57ff2878aa3d1.tar.gz bcm5719-llvm-ad80af8f191503fe33deecf8efc57ff2878aa3d1.zip |
-Wempty-body: fix false negative triggered by macros
When if statement condition ended in a macro:
if (ptr == NULL);
the check used to consider the definition location of NULL, instead of the
current line.
Patch by Manasij Mukherjee.
llvm-svn: 232295
Diffstat (limited to 'clang/test/SemaCXX/warn-empty-body.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-empty-body.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-empty-body.cpp b/clang/test/SemaCXX/warn-empty-body.cpp index d3aaac1d8c3..a248c4251d5 100644 --- a/clang/test/SemaCXX/warn-empty-body.cpp +++ b/clang/test/SemaCXX/warn-empty-body.cpp @@ -4,10 +4,17 @@ void a(int i); int b(); int c(); +#define MACRO_A 0 + void test1(int x, int y) { while(true) { if (x); // expected-warning {{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}} + // Check that we handle conditions that start or end with a macro + // correctly. + if (x == MACRO_A); // expected-warning {{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}} + if (MACRO_A == x); // expected-warning {{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}} + int i; // PR11329 for (i = 0; i < x; i++); { // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}} |