[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / attr-unavailable-message.c
blobb4ae70e0a39cba340d3c0f6a620c461bc8ad9589
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // rdar: //6734520
4 void tooManyArgs(void) __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}
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}}
9 void bar(void) __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
11 int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}}
13 #define ACCEPTABLE "Use something else"
14 int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
16 void test_foo(void) {
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}}
20 void (*fp)(void) = &bar; // expected-error {{'bar' is unavailable}}
22 double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
25 char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
27 // rdar://9623855
28 void unavail(void) __attribute__((__unavailable__));
29 void unavail(void) {
30 // No complains inside an unavailable function.
31 int ir = foo(1);
32 double dr = dfoo(1.0);
33 void (*fp)(void) = &bar;
34 double (*fp4)(double) = dfoo;
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}}
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()));
50 enum fee f(void) { // expected-error {{'fee' is unavailable}}
51 int i = a; // expected-warning {{'a' is deprecated}}
53 i = b; // expected-warning {{'b' is deprecated}}
55 return r; // expected-error {{'r' is unavailable}}