annotate clang/test/Sema/attr-deprecated-c2x.c @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children 5f17cb93ff66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -verify -fsyntax-only --std=c2x
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 int f() [[deprecated]]; // expected-note 2 {{'f' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
4 void g() [[deprecated]];// expected-note {{'g' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
5 void g();
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 extern int var [[deprecated]]; // expected-note 2 {{'var' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 int a() {
anatofuz
parents:
diff changeset
10 int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
anatofuz
parents:
diff changeset
11 f(); // expected-warning {{'f' is deprecated}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 // test if attributes propagate to functions
anatofuz
parents:
diff changeset
14 g(); // expected-warning {{'g' is deprecated}}
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 return var; // expected-warning {{'var' is deprecated}}
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 // test if attributes propagate to variables
anatofuz
parents:
diff changeset
20 extern int var;
anatofuz
parents:
diff changeset
21 int w() {
anatofuz
parents:
diff changeset
22 return var; // expected-warning {{'var' is deprecated}}
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 int old_fn() [[deprecated]];// expected-note {{'old_fn' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
26 int old_fn();
anatofuz
parents:
diff changeset
27 int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 int old_fn() {
anatofuz
parents:
diff changeset
30 return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 struct foo {
anatofuz
parents:
diff changeset
34 int x [[deprecated]]; // expected-note 3 {{'x' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
35 };
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 void test1(struct foo *F) {
anatofuz
parents:
diff changeset
38 ++F->x; // expected-warning {{'x' is deprecated}}
anatofuz
parents:
diff changeset
39 struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}}
anatofuz
parents:
diff changeset
40 struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 typedef struct foo foo_dep [[deprecated]]; // expected-note {{'foo_dep' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
44 foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 struct [[deprecated, // expected-note {{'bar_dep' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
47 invalid_attribute]] bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 [[deprecated("this is the message")]] int i; // expected-note {{'i' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
52 void test4(void) {
anatofuz
parents:
diff changeset
53 i = 12; // expected-warning {{'i' is deprecated: this is the message}}
anatofuz
parents:
diff changeset
54 }