brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · c5f13c3 Raw
54 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3void tooManyArgs(void) __attribute__((unavailable("a", "b"))); // expected-error {{'unavailable' attribute takes no more than 1 argument}}4 5int foo(int)  __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{'foo' has been explicitly marked unavailable here}}6double dfoo(double)  __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}7 8void bar(void) __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}9 10int quux(void) __attribute__((__unavailable__(12))); // expected-error {{expected string literal as argument of '__unavailable__' attribute}}11 12#define ACCEPTABLE	"Use something else"13int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));14 15void 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}}18 19  void (*fp)(void) = &bar; // expected-error {{'bar' is unavailable}}20 21  double (*fp4)(double) = dfoo;  // expected-error {{'dfoo' is unavailable: NO LONGER}}22}23 24char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];25 26void unavail(void)  __attribute__((__unavailable__));27void 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;33}34 35enum foo {36    a = 1,37    b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}}38    c = 339}__attribute__((deprecated())); // expected-note {{'foo' has been explicitly marked deprecated here}}40 41enum fee { // expected-note 2 {{'fee' has been explicitly marked unavailable here}}42    r = 1,43    s = 2,44    t = 345}__attribute__((unavailable()));46 47enum fee f(void) { // expected-error {{'fee' is unavailable}}48    int i = a; // expected-warning {{'a' is deprecated}}49 50    i = b; // expected-warning {{'b' is deprecated}}51 52    return r; // expected-error {{'r' is unavailable}}53}54