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