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