Home | History | Annotate | Download | only in Sema
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 // rdar: //6734520
      3 
      4 int foo(int)  __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}
      5 double dfoo(double)  __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
      6 
      7 void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
      8 
      9 int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
     10 
     11 #define ACCEPTABLE	"Use something else"
     12 int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
     13 
     14 void test_foo() {
     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}}
     17 
     18   void (*fp)() = &bar; // expected-error {{'bar' is unavailable}}
     19 
     20   double (*fp4)(double) = dfoo;  // expected-error {{'dfoo' is unavailable: NO LONGER}}
     21 }
     22 
     23 char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
     24 
     25 // rdar://9623855
     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)() = &bar;
     32   double (*fp4)(double) = dfoo;
     33 }
     34 
     35 // rdar://10201690
     36 enum foo {
     37     a = 1, // expected-note {{'a' has been explicitly marked deprecated here}}
     38     b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}}
     39     c = 3
     40 }__attribute__((deprecated()));
     41 
     42 enum fee { // expected-note {{'fee' has been explicitly marked unavailable here}}
     43     r = 1, // expected-note {{'r' has been explicitly marked unavailable here}}
     44     s = 2,
     45     t = 3
     46 }__attribute__((unavailable()));
     47 
     48 enum fee f() { // expected-error {{'fee' is unavailable}}
     49     int i = a; // expected-warning {{'a' is deprecated}}
     50 
     51     i = b; // expected-warning {{'b' is deprecated}}
     52 
     53     return r; // expected-error {{'r' is unavailable}}
     54 }
     55