1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 // PR4103 : Make sure we don't get a bogus unused expression warning 4 namespace PR4103 { 5 class APInt { 6 char foo; 7 }; 8 class APSInt : public APInt { 9 char bar; 10 public: 11 APSInt &operator=(const APSInt &RHS); 12 }; 13 operator =(const APSInt & RHS)14 APSInt& APSInt::operator=(const APSInt &RHS) { 15 APInt::operator=(RHS); 16 return *this; 17 } 18 19 template<typename T> 20 struct X { 21 X(); 22 }; 23 test()24 void test() { 25 X<int>(); 26 } 27 } 28 29 namespace derefvolatile { f(volatile char * x)30 void f(volatile char* x) { 31 *x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} 32 (void)*x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} 33 volatile char y = 10; 34 (void)y; // don't warn here, because it's a common pattern. 35 } 36 } 37 38 // <rdar://problem/12359208> 39 namespace AnonObject { 40 struct Foo { 41 Foo(const char* const message); 42 ~Foo(); 43 }; f()44 void f() { 45 Foo("Hello World!"); // don't warn 46 int(1); // expected-warning {{expression result unused}} 47 } 48 } 49 50 // Test that constructing an object (which may have side effects) with 51 // constructor arguments which are dependent doesn't produce an unused value 52 // warning. 53 namespace UnresolvedLookup { 54 struct Foo { 55 Foo(int i, int j); 56 }; 57 template <typename T> 58 struct Bar { fUnresolvedLookup::Bar59 void f(T t) { 60 Foo(t, 0); // no warning 61 } 62 }; 63 } 64