• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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