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{{function 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