Fariborz Jahanian | c784dc1 | 2010-10-06 23:12:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | // rdar: //6734520 |
| 3 | |
| 4 | int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{function has been explicitly marked unavailable here}} |
| 5 | double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{function has been explicitly marked unavailable here}} |
| 6 | |
| 7 | void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}} |
| 8 | |
| 9 | void test_foo() { |
| 10 | int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}} |
| 11 | double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}} |
| 12 | |
| 13 | void (*fp)() = &bar; // expected-error {{'bar' is unavailable}} |
| 14 | |
| 15 | double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}} |
| 16 | } |
John McCall | 4820908 | 2010-11-08 19:48:17 +0000 | [diff] [blame] | 17 | |
| 18 | char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1]; |
Argyrios Kyrtzidis | 12189f5 | 2011-06-17 17:28:30 +0000 | [diff] [blame] | 19 | |
| 20 | // rdar://9623855 |
| 21 | void unavail(void) __attribute__((__unavailable__)); |
| 22 | void unavail(void) { |
| 23 | // No complains inside an unavailable function. |
| 24 | int ir = foo(1); |
| 25 | double dr = dfoo(1.0); |
| 26 | void (*fp)() = &bar; |
| 27 | double (*fp4)(double) = dfoo; |
| 28 | } |
Fariborz Jahanian | 97db726 | 2011-09-29 18:40:01 +0000 | [diff] [blame] | 29 | |
| 30 | // rdar://10201690 |
| 31 | enum foo { |
Eli Friedman | c3b2308 | 2012-08-08 21:52:41 +0000 | [diff] [blame] | 32 | a = 1, // expected-note {{declared here}} |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 33 | b __attribute__((deprecated())) = 2, // expected-note {{declared here}} |
Fariborz Jahanian | 97db726 | 2011-09-29 18:40:01 +0000 | [diff] [blame] | 34 | c = 3 |
| 35 | }__attribute__((deprecated())); |
| 36 | |
Fariborz Jahanian | 39b4fc8 | 2011-11-28 19:45:58 +0000 | [diff] [blame] | 37 | enum fee { // expected-note {{declaration has been explicitly marked unavailable here}} |
| 38 | r = 1, // expected-note {{declaration has been explicitly marked unavailable here}} |
Fariborz Jahanian | 97db726 | 2011-09-29 18:40:01 +0000 | [diff] [blame] | 39 | s = 2, |
| 40 | t = 3 |
| 41 | }__attribute__((unavailable())); |
| 42 | |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 43 | enum fee f() { // expected-error {{'fee' is unavailable}} |
| 44 | int i = a; // expected-warning {{'a' is deprecated}} |
Fariborz Jahanian | 97db726 | 2011-09-29 18:40:01 +0000 | [diff] [blame] | 45 | |
| 46 | i = b; // expected-warning {{'b' is deprecated}} |
| 47 | |
Fariborz Jahanian | 39b4fc8 | 2011-11-28 19:45:58 +0000 | [diff] [blame] | 48 | return r; // expected-error {{'r' is unavailable}} |
Fariborz Jahanian | 97db726 | 2011-09-29 18:40:01 +0000 | [diff] [blame] | 49 | } |