| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
void tooManyArgs(void) __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}} |
| 4 |
|
| 5 |
int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}} |
| 6 |
double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}} |
| 7 |
|
| 8 |
void bar(void) __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}} |
| 9 |
|
| 10 |
int quux(void) __attribute__((__unavailable__(12))); // expected-error {{expected string literal as argument of '__unavailable__' attribute}} |
| 11 |
|
| 12 |
#define ACCEPTABLE "Use something else" |
| 13 |
int quux2(void) __attribute__((__unavailable__(ACCEPTABLE))); |
| 14 |
|
| 15 |
void test_foo(void) { |
| 16 |
int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}} |
| 17 |
double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}} |
| 18 |
|
| 19 |
void (*fp)(void) = &bar; // expected-error {{'bar' is unavailable}} |
| 20 |
|
| 21 |
double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}} |
| 22 |
} |
| 23 |
|
| 24 |
char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1]; |
| 25 |
|
| 26 |
void unavail(void) __attribute__((__unavailable__)); |
| 27 |
void unavail(void) { |
| 28 |
// No complains inside an unavailable function. |
| 29 |
int ir = foo(1); |
| 30 |
double dr = dfoo(1.0); |
| 31 |
void (*fp)(void) = &bar; |
| 32 |
double (*fp4)(double) = dfoo; |
| 33 |
} |
| 34 |
|
| 35 |
enum foo { |
| 36 |
a = 1, |
| 37 |
b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}} |
| 38 |
c = 3 |
| 39 |
}__attribute__((deprecated())); // expected-note {{'foo' has been explicitly marked deprecated here}} |
| 40 |
|
| 41 |
enum fee { // expected-note 2 {{'fee' has been explicitly marked unavailable here}} |
| 42 |
r = 1, |
| 43 |
s = 2, |
| 44 |
t = 3 |
| 45 |
}__attribute__((unavailable())); |
| 46 |
|
| 47 |
enum fee f(void) { // expected-error {{'fee' is unavailable}} |
| 48 |
int i = a; // expected-warning {{'a' is deprecated}} |
| 49 |
|
| 50 |
i = b; // expected-warning {{'b' is deprecated}} |
| 51 |
|
| 52 |
return r; // expected-error {{'r' is unavailable}} |
| 53 |
} |