blob: 80298ec6664a8820f70a41c17e7ab7591dc40601 [file] [log] [blame]
John McCall0faede62010-03-12 07:11:26 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
2
3// PR4806
4namespace test0 {
5 class Box {
6 public:
7 int i;
8 volatile int j;
9 };
10
11 void doit() {
12 // pointer to volatile has side effect (thus no warning)
13 Box* box = new Box;
14 box->i; // expected-warning {{expression result unused}}
15 box->j;
16 }
17}
Matt Beaumont-Gay6e521832011-09-19 18:51:20 +000018
19namespace test1 {
20struct Foo {
21 int i;
22 bool operator==(const Foo& rhs) {
23 return i == rhs.i;
24 }
25};
26
27#define NOP(x) (x)
28void b(Foo f1, Foo f2) {
29 NOP(f1 == f2); // expected-warning {{expression result unused}}
30}
31#undef NOP
32}