blob: b4ef1bbeaf0ef1283abe51c892e3f4a7b197bd60 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc %s -fsyntax-only -verify
Chris Lattner026dc962009-02-14 07:37:35 +00002// rdar://6587766
3
4int fn1() __attribute__ ((warn_unused_result));
5int fn2() __attribute__ ((pure));
6int fn3() __attribute__ ((const));
7
8int 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
18int bar __attribute__ ((warn_unused_result)); // expected-warning {{warning: 'warn_unused_result' attribute only applies to function types}}
19