annotate clang/test/Sema/ast-print.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -ast-print -verify > %t.c
anatofuz
parents:
diff changeset
2 // RUN: FileCheck %s --input-file %t.c
anatofuz
parents:
diff changeset
3 //
anatofuz
parents:
diff changeset
4 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
anatofuz
parents:
diff changeset
5 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"
anatofuz
parents:
diff changeset
6 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked deprecated here}}"
anatofuz
parents:
diff changeset
7 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is deprecated}}"
anatofuz
parents:
diff changeset
8 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been explicitly marked deprecated here}}"
anatofuz
parents:
diff changeset
9 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is deprecated}}"
anatofuz
parents:
diff changeset
10 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been explicitly marked deprecated here}}"
anatofuz
parents:
diff changeset
11 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 typedef void func_typedef();
anatofuz
parents:
diff changeset
14 func_typedef xxx;
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 typedef void func_t(int x);
anatofuz
parents:
diff changeset
17 func_t a;
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 struct blah {
anatofuz
parents:
diff changeset
20 struct {
anatofuz
parents:
diff changeset
21 struct {
anatofuz
parents:
diff changeset
22 int b;
anatofuz
parents:
diff changeset
23 };
anatofuz
parents:
diff changeset
24 };
anatofuz
parents:
diff changeset
25 };
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 // This used to crash clang.
anatofuz
parents:
diff changeset
28 struct {
anatofuz
parents:
diff changeset
29 }(s1);
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 int foo(const struct blah *b) {
anatofuz
parents:
diff changeset
32 // CHECK: return b->b;
anatofuz
parents:
diff changeset
33 return b->b;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 int arr(int a[static 3]) {
anatofuz
parents:
diff changeset
37 // CHECK: int a[static 3]
anatofuz
parents:
diff changeset
38 return a[2];
anatofuz
parents:
diff changeset
39 }
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 int rarr(int a[restrict static 3]) {
anatofuz
parents:
diff changeset
42 // CHECK: int a[restrict static 3]
anatofuz
parents:
diff changeset
43 return a[2];
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 int varr(int n, int a[static n]) {
anatofuz
parents:
diff changeset
47 // CHECK: int a[static n]
anatofuz
parents:
diff changeset
48 return a[2];
anatofuz
parents:
diff changeset
49 }
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 int rvarr(int n, int a[restrict static n]) {
anatofuz
parents:
diff changeset
52 // CHECK: int a[restrict static n]
anatofuz
parents:
diff changeset
53 return a[2];
anatofuz
parents:
diff changeset
54 }
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 // CHECK: typedef struct {
anatofuz
parents:
diff changeset
57 typedef struct {
anatofuz
parents:
diff changeset
58 int f;
anatofuz
parents:
diff changeset
59 } T __attribute__ ((__aligned__));
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 // CHECK: struct __attribute__((visibility("default"))) S;
anatofuz
parents:
diff changeset
62 struct __attribute__((visibility("default"))) S;
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 struct pair_t {
anatofuz
parents:
diff changeset
65 int a;
anatofuz
parents:
diff changeset
66 int b;
anatofuz
parents:
diff changeset
67 };
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 // CHECK: struct pair_t p = {a: 3, .b = 4};
anatofuz
parents:
diff changeset
70 struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style field designator extension}}
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 void initializers() {
anatofuz
parents:
diff changeset
73 // CHECK: int *x = ((void *)0), *y = ((void *)0);
anatofuz
parents:
diff changeset
74 int *x = ((void *)0), *y = ((void *)0);
anatofuz
parents:
diff changeset
75 struct Z{};
anatofuz
parents:
diff changeset
76 struct {
anatofuz
parents:
diff changeset
77 struct Z z;
anatofuz
parents:
diff changeset
78 // CHECK: } z = {(struct Z){}};
anatofuz
parents:
diff changeset
79 } z = {(struct Z){}};
anatofuz
parents:
diff changeset
80 }
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 // CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
anatofuz
parents:
diff changeset
83 enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is deprecated}}
anatofuz
parents:
diff changeset
84 // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
anatofuz
parents:
diff changeset
85 EnumWithAttributesFoo __attribute__((deprecated)),
anatofuz
parents:
diff changeset
86 // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
anatofuz
parents:
diff changeset
87 EnumWithAttributesBar __attribute__((unavailable)) = 50
anatofuz
parents:
diff changeset
88 // CHECK-NEXT: } *EnumWithAttributesPtr;
anatofuz
parents:
diff changeset
89 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note {{'EnumWithAttributes' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 // CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr;
anatofuz
parents:
diff changeset
92 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
anatofuz
parents:
diff changeset
93 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
94 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 // CHECK-LABEL: EnumWithAttributes3Fn
anatofuz
parents:
diff changeset
97 void EnumWithAttributes3Fn() {
anatofuz
parents:
diff changeset
98 // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 *EnumWithAttributes3Ptr;
anatofuz
parents:
diff changeset
99 // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
anatofuz
parents:
diff changeset
100 // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
101 enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
anatofuz
parents:
diff changeset
102 // Printing must not put the attribute after the tag where it would apply to
anatofuz
parents:
diff changeset
103 // the variable instead of the type, and then our deprecation warning would
anatofuz
parents:
diff changeset
104 // move to this use of the variable.
anatofuz
parents:
diff changeset
105 void *p = EnumWithAttributes3Ptr;
anatofuz
parents:
diff changeset
106 }