Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 int &foo(int); // expected-note {{candidate}}
      4 double &foo(double); // expected-note {{candidate}}
      5 void foo(...) __attribute__((__unavailable__)); // expected-note {{candidate function}} \
      6 // expected-note{{'foo' has been explicitly marked unavailable here}}
      7 
      8 void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly marked unavailable}}
      9 
     10 void test_foo(short* sp) {
     11   int &ir = foo(1);
     12   double &dr = foo(1.0);
     13   foo(sp); // expected-error{{call to unavailable function 'foo'}}
     14 
     15   void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}}
     16   void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}}
     17 
     18   int &(*fp3)(int) = foo;
     19   void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}}
     20 }
     21 
     22 namespace radar9046492 {
     23 // rdar://9046492
     24 #define FOO __attribute__((unavailable("not available - replaced")))
     25 
     26 void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}}
     27 void bar() {
     28   foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}}
     29 }
     30 }
     31 
     32 void unavail(short* sp)  __attribute__((__unavailable__));
     33 void unavail(short* sp) {
     34   // No complains inside an unavailable function.
     35   int &ir = foo(1);
     36   double &dr = foo(1.0);
     37   foo(sp);
     38   foo();
     39 }
     40 
     41 // Show that delayed processing of 'unavailable' is the same
     42 // delayed process for 'deprecated'.
     43 // <rdar://problem/12241361> and <rdar://problem/15584219>
     44 enum DeprecatedEnum { DE_A, DE_B } __attribute__((deprecated)); // expected-note {{'DeprecatedEnum' has been explicitly marked deprecated here}}
     45 __attribute__((deprecated)) typedef enum DeprecatedEnum DeprecatedEnum;
     46 typedef enum DeprecatedEnum AnotherDeprecatedEnum; // expected-warning {{'DeprecatedEnum' is deprecated}}
     47 
     48 __attribute__((deprecated))
     49 DeprecatedEnum testDeprecated(DeprecatedEnum X) { return X; }
     50 
     51 
     52 enum UnavailableEnum { UE_A, UE_B } __attribute__((unavailable)); // expected-note {{'UnavailableEnum' has been explicitly marked unavailable here}}
     53 __attribute__((unavailable)) typedef enum UnavailableEnum UnavailableEnum;
     54 typedef enum UnavailableEnum AnotherUnavailableEnum; // expected-error {{'UnavailableEnum' is unavailable}}
     55 
     56 
     57 __attribute__((unavailable))
     58 UnavailableEnum testUnavailable(UnavailableEnum X) { return X; }
     59