Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / attr-unavailable-message.c
blobc5f13c330696c3b10559eee890c472155d9608e1
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 void tooManyArgs(void) __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}
5 int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}
6 double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
8 void bar(void) __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
10 int quux(void) __attribute__((__unavailable__(12))); // expected-error {{expected string literal as argument of '__unavailable__' attribute}}
12 #define ACCEPTABLE "Use something else"
13 int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
15 void test_foo(void) {
16 int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
17 double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
19 void (*fp)(void) = &bar; // expected-error {{'bar' is unavailable}}
21 double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
24 char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
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)(void) = &bar;
32 double (*fp4)(double) = dfoo;
35 enum foo {
36 a = 1,
37 b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}}
38 c = 3
39 }__attribute__((deprecated())); // expected-note {{'foo' has been explicitly marked deprecated here}}
41 enum fee { // expected-note 2 {{'fee' has been explicitly marked unavailable here}}
42 r = 1,
43 s = 2,
44 t = 3
45 }__attribute__((unavailable()));
47 enum fee f(void) { // expected-error {{'fee' is unavailable}}
48 int i = a; // expected-warning {{'a' is deprecated}}
50 i = b; // expected-warning {{'b' is deprecated}}
52 return r; // expected-error {{'r' is unavailable}}