Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | c6666f8 | 2009-02-18 06:34:51 +0000 | [diff] [blame] | 2 | |
John McCall | 8120162 | 2010-01-08 04:41:39 +0000 | [diff] [blame] | 3 | int &foo(int); // expected-note {{candidate}} |
| 4 | double &foo(double); // expected-note {{candidate}} |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 5 | void foo(...) __attribute__((__unavailable__)); // expected-note {{candidate function}} \ |
| 6 | // expected-note{{function has been explicitly marked unavailable here}} |
| 7 | |
| 8 | void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly marked unavailable}} |
Douglas Gregor | c6666f8 | 2009-02-18 06:34:51 +0000 | [diff] [blame] | 9 | |
| 10 | void test_foo(short* sp) { |
| 11 | int &ir = foo(1); |
| 12 | double &dr = foo(1.0); |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 13 | foo(sp); // expected-error{{call to unavailable function 'foo'}} |
| 14 | |
Ted Kremenek | 042411c | 2010-07-21 20:43:11 +0000 | [diff] [blame] | 15 | void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}} |
| 16 | void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}} |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 17 | |
| 18 | int &(*fp3)(int) = foo; |
Ted Kremenek | 042411c | 2010-07-21 20:43:11 +0000 | [diff] [blame] | 19 | void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}} |
Douglas Gregor | c6666f8 | 2009-02-18 06:34:51 +0000 | [diff] [blame] | 20 | } |
Fariborz Jahanian | 2b982b7 | 2011-02-25 18:38:59 +0000 | [diff] [blame] | 21 | |
| 22 | namespace radar9046492 { |
| 23 | // rdar://9046492 |
| 24 | #define FOO __attribute__((unavailable("not available - replaced"))) |
| 25 | |
| 26 | void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}} |
Fariborz Jahanian | 2b982b7 | 2011-02-25 18:38:59 +0000 | [diff] [blame] | 27 | void bar() { |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 28 | foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}} |
Fariborz Jahanian | 2b982b7 | 2011-02-25 18:38:59 +0000 | [diff] [blame] | 29 | } |
| 30 | } |
Argyrios Kyrtzidis | 572bbec | 2011-06-23 00:41:50 +0000 | [diff] [blame^] | 31 | |
| 32 | void unavail(short* sp) __attribute__((__unavailable__)); |
| 33 | void unavail(short* sp) { |
| 34 | // No complains inside an unavailable function. |
| 35 | int &ir = foo(1); |
| 36 | double &dr = foo(1.0); |
| 37 | foo(sp); |
| 38 | foo(); |
| 39 | } |