1 // RUN: %clang_cc1 -fsyntax-only -verify %s
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}}
7 void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
9 int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
11 #define ACCEPTABLE "Use something else"
12 int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
15 int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
16 double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
18 void (*fp)() = &bar; // expected-error {{'bar' is unavailable}}
20 double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
23 char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
26 void unavail(void) __attribute__((__unavailable__));
28 // No complains inside an unavailable function.
30 double dr = dfoo(1.0);
32 double (*fp4)(double) = dfoo;
37 a = 1, // expected-note {{declared here}}
38 b __attribute__((deprecated())) = 2, // expected-note {{declared here}}
40 }__attribute__((deprecated()));
42 enum fee { // expected-note {{declaration has been explicitly marked unavailable here}}
43 r = 1, // expected-note {{declaration has been explicitly marked unavailable here}}
46 }__attribute__((unavailable()));
48 enum fee f() { // expected-error {{'fee' is unavailable}}
49 int i = a; // expected-warning {{'a' is deprecated}}
51 i = b; // expected-warning {{'b' is deprecated}}
53 return r; // expected-error {{'r' is unavailable}}