1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 void tooManyArgs() __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}
6 int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}
7 double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
9 void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
11 int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
13 #define ACCEPTABLE "Use something else"
14 int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
17 int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
18 double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
20 void (*fp)() = &bar; // expected-error {{'bar' is unavailable}}
22 double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
25 char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
28 void unavail(void) __attribute__((__unavailable__));
30 // No complains inside an unavailable function.
32 double dr = dfoo(1.0);
34 double (*fp4)(double) = dfoo;
39 a = 1, // expected-note {{'a' has been explicitly marked deprecated here}}
40 b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}}
42 }__attribute__((deprecated()));
44 enum fee { // expected-note {{'fee' has been explicitly marked unavailable here}}
45 r = 1, // expected-note {{'r' has been explicitly marked unavailable here}}
48 }__attribute__((unavailable()));
50 enum fee f() { // expected-error {{'fee' is unavailable}}
51 int i = a; // expected-warning {{'a' is deprecated}}
53 i = b; // expected-warning {{'b' is deprecated}}
55 return r; // expected-error {{'r' is unavailable}}