diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /test/Sema/unused-expr.c | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/Sema/unused-expr.c')
-rw-r--r-- | test/Sema/unused-expr.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index aa81febd..ea08631 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -123,13 +123,36 @@ void f(int i, ...) { // PR8371 int fn5() __attribute__ ((__const)); -// OpenSSL has some macros like this; we shouldn't warn on the cast. +// Don't warn for unused expressions in macro bodies; however, do warn for +// unused expressions in macro arguments. Macros below are reduced from code +// found in the wild. +#define NOP(a) (a) #define M1(a, b) (long)foo((a), (b)) -// But, we should still warn on other subexpressions of casts in macros. #define M2 (long)0; +#define M3(a) (t3(a), fn2()) +#define M4(a, b) (foo((a), (b)) ? 0 : t3(a), 1) +#define M5(a, b) (foo((a), (b)), 1) +#define M6() fn1() +#define M7() fn2() void t11(int i, int j) { M1(i, j); // no warning - M2; // expected-warning {{expression result unused}} + NOP((long)foo(i, j)); // expected-warning {{expression result unused}} + M2; // no warning + NOP((long)0); // expected-warning {{expression result unused}} + M3(i); // no warning + NOP((t3(i), fn2())); // expected-warning {{ignoring return value}} + M4(i, j); // no warning + NOP((foo(i, j) ? 0 : t3(i), 1)); // expected-warning {{expression result unused}} + M5(i, j); // no warning + NOP((foo(i, j), 1)); // expected-warning {{expression result unused}} + M6(); // expected-warning {{ignoring return value}} + M7(); // no warning } +#undef NOP #undef M1 #undef M2 +#undef M3 +#undef M4 +#undef M5 +#undef M6 +#undef M7 |