Daniel Dunbar | 80737ad | 2009-12-15 22:01:24 +0000 | [diff] [blame] | 1 | // RUN: %clang -fsyntax-only -Wunused-variable -verify %s |
Douglas Gregor | b5352cf | 2009-10-08 21:35:42 +0000 | [diff] [blame] | 2 | |
| 3 | template<typename T> void f() { |
| 4 | T t; |
| 5 | t = 17; |
| 6 | } |
Anders Carlsson | f7613d5 | 2009-11-07 07:26:56 +0000 | [diff] [blame] | 7 | |
Anders Carlsson | 6a8b7f3 | 2009-11-07 08:24:59 +0000 | [diff] [blame] | 8 | // PR5407 |
Anders Carlsson | f7613d5 | 2009-11-07 07:26:56 +0000 | [diff] [blame] | 9 | struct A { A(); }; |
| 10 | struct B { ~B(); }; |
Anders Carlsson | f7613d5 | 2009-11-07 07:26:56 +0000 | [diff] [blame] | 11 | void f() { |
| 12 | A a; |
| 13 | B b; |
Anders Carlsson | 6a8b7f3 | 2009-11-07 08:24:59 +0000 | [diff] [blame] | 14 | } |
Anders Carlsson | 58beed9 | 2009-11-17 17:11:23 +0000 | [diff] [blame] | 15 | |
| 16 | // PR5531 |
| 17 | namespace PR5531 { |
| 18 | struct A { |
| 19 | }; |
| 20 | |
| 21 | struct B { |
| 22 | B(int); |
| 23 | }; |
| 24 | |
| 25 | struct C { |
| 26 | ~C(); |
| 27 | }; |
| 28 | |
| 29 | void test() { |
| 30 | A(); |
| 31 | B(17); |
| 32 | C(); |
| 33 | } |
| 34 | } |
Nuno Lopes | cb1c77f | 2009-12-24 00:28:18 +0000 | [diff] [blame^] | 35 | |
| 36 | |
| 37 | struct X { |
| 38 | int foo() __attribute__((warn_unused_result)); |
| 39 | }; |
| 40 | |
| 41 | void bah() { |
| 42 | X x, *x2; |
| 43 | x.foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}} |
| 44 | x2->foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}} |
| 45 | } |