brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · d0d7634 Raw
59 lines · c
1// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c2x2 3[[deprecated]] int f(void); // expected-note 2 {{'f' has been explicitly marked deprecated here}}4[[deprecated]] void g(void);// expected-note {{'g' has been explicitly marked deprecated here}}5void g(void);6 7extern int var [[deprecated]]; // expected-note 2 {{'var' has been explicitly marked deprecated here}}8 9int a(void) {10  int (*ptr)(void) = f; // expected-warning {{'f' is deprecated}}11  f(); // expected-warning {{'f' is deprecated}}12 13  // test if attributes propagate to functions14  g(); // expected-warning {{'g' is deprecated}}15 16  return var; // expected-warning {{'var' is deprecated}}17}18 19// test if attributes propagate to variables20extern int var;21int w(void) {22  return var; // expected-warning {{'var' is deprecated}}23}24 25[[deprecated]] int old_fn(void);// expected-note {{'old_fn' has been explicitly marked deprecated here}}26int old_fn(void);27int (*fn_ptr)(void) = old_fn; // expected-warning {{'old_fn' is deprecated}}28 29int old_fn(void) {30  return old_fn()+1;  // no warning, deprecated functions can use deprecated symbols.31}32 33struct foo {34  int x [[deprecated]]; // expected-note 3 {{'x' has been explicitly marked deprecated here}}35};36 37void test1(struct foo *F) {38  ++F->x;  // expected-warning {{'x' is deprecated}}39  struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}}40  struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}41}42 43typedef struct foo foo_dep [[deprecated]]; // expected-note {{'foo_dep' has been explicitly marked deprecated here}}44foo_dep *test2;    // expected-warning {{'foo_dep' is deprecated}}45 46struct [[deprecated, // expected-note {{'bar_dep' has been explicitly marked deprecated here}}47         invalid_attribute]] bar_dep ;  // expected-warning {{unknown attribute 'invalid_attribute' ignored}}48 49struct bar_dep *test3;   // expected-warning {{'bar_dep' is deprecated}}50 51[[deprecated("this is the message")]] int i; // expected-note {{'i' has been explicitly marked deprecated here}}52void test4(void) {53  i = 12; // expected-warning {{'i' is deprecated: this is the message}}54}55 56// Ensure that deprecated only accepts one argument, not the replacement57// argument supported as a GNU extension.58[[deprecated("message", "replacement not supported")]] void test5(void); // expected-error {{'deprecated' attribute takes no more than 1 argument}}59