Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc %s -fsyntax-only -verify |
Chris Lattner | 026dc96 | 2009-02-14 07:37:35 +0000 | [diff] [blame] | 2 | // rdar://6587766 |
| 3 | |
| 4 | int fn1() __attribute__ ((warn_unused_result)); |
| 5 | int fn2() __attribute__ ((pure)); |
| 6 | int fn3() __attribute__ ((const)); |
| 7 | |
| 8 | int foo() { |
| 9 | if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings |
| 10 | return -1; |
| 11 | |
| 12 | fn1(); // expected-warning {{expression result unused}} |
| 13 | fn2(92, 21); // expected-warning {{expression result unused}} |
| 14 | fn3(42); // expected-warning {{expression result unused}} |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | int bar __attribute__ ((warn_unused_result)); // expected-warning {{warning: 'warn_unused_result' attribute only applies to function types}} |
| 19 | |