blob: 38f201ca82502f71b034a2f2c505b3baeb9301fa [file] [log] [blame]
Chris Lattner026dc962009-02-14 07:37:35 +00001// RUN: clang %s -fsyntax-only -verify
2// 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